db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernt M. Johnsen" <Bernt.John...@Sun.COM>
Subject Re: SQL Exception
Date Wed, 01 Mar 2006 11:55:02 GMT
>>>>>>>>>>>> Bernt M. Johnsen wrote (2006-03-01 10:27:57):
> 
> Hi,
> 
> You are calling setObject(....null) and should have called setNull(...)
> 
> There is a big difference between Java null (an empty reference) and
> SQL NULL (an undefined value).

To be precise:
You may not call setObject("middle_name", null), but you may call
one of the following

setObject("middle_name", null, java.sql.Types.VARCHAR)
   or
setNull("middle_name", java.sql.Types.VARCHAR)
   or
setString("middle_name", null);






> 
> 
> >>>>>>>>>>>> meenakshi selvi wrote (2006-03-01 05:26:59):
> > hi all,
> >   i have created a table in derby as follow
> >   
> > create table sp_ss_ex_contact(
> >   email       varchar(200)  primary key,
> >    first_name  varchar(50) not null    ,
> >    middle_name varchar(50)             ,
> >    last_name   varchar(50) not null    ,
> >    telephone   varchar(20 )            ,
> >    address     varchar(250)            ,
> >    state       char   (1  ) not null   ,
> >    last_update timestamp not null
> > );
> >    
> >   if any of the rows in the columns middle name,telephone and address is null,it
throws the following exception,
> >   
> > SQL Exception: An attempt was made to get a data value of type 'VARCHAR' from a
> > data value of type 'null'.
> >         at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
> >         at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
> >         at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source
> > )
> >         at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown So
> > urce)
> >         at org.apache.derby.impl.jdbc.ConnectionChild.newSQLException(Unknown So
> > urce)
> >         at org.apache.derby.impl.jdbc.EmbedPreparedStatement.dataTypeConversion(
> > Unknown Source)
> >         at org.apache.derby.impl.jdbc.EmbedPreparedStatement.setObject(Unknown S
> > ource)
> >    
> >   
> > please help me.
> > 
> > 				
> > ---------------------------------
> >  Jiyo cricket on Yahoo! India cricket
> > Yahoo! Messenger Mobile Stay in touch with your buddies all the time.
> 
> -- 
> Bernt Marius Johnsen, Database Technology Group, 
> Staff Engineer, Technical Lead Derby/Java DB
> Sun Microsystems, Trondheim, Norway



-- 
Bernt Marius Johnsen, Database Technology Group, 
Staff Engineer, Technical Lead Derby/Java DB
Sun Microsystems, Trondheim, Norway

Mime
View raw message