I have to say I don't understand the rationale for throwing an exception here. Looking at the stack trace, I agree with Bernt that the user is calling setObject(column, null). What I don't agree with is that there is any ambiguity as to what the user means.

The setObject javadoc sez:

The JDBC specification specifies a standard mapping from Java Object types to SQL types. The given argument will be converted to the corresponding SQL type before being sent to the database....This method throws an exception if there is an ambiguity, for example, if the object is of a class implementing more than one of the interfaces named above.

more below...

On Mar 1, 2006, at 3:55 AM, Bernt M. Johnsen wrote:

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

I think that for parameters that implement multiple interfaces, there is ambiguity. Where is the ambiguity in trying to set a column of type VARCHAR to null?

Craig








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

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:[EMAIL PROTECTED]
P.S. A good JDO? O, Gasp!

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to