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 09:27:57 GMT

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).


>>>>>>>>>>>> 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

Mime
View raw message