db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Army <qoz...@sbcglobal.net>
Subject setNull() using Types.VARCHAR for a CLOB parameter fails in embedded mode.
Date Fri, 14 Oct 2005 00:36:07 GMT
If I attempt to call PreparedStatement.setNull() and specify Types.VARCHAR when 
the actual parameter type (as determined at bind time) is CLOB, Derby in 
embedded mode will throw an error, while Derby in client/server mode will succeed.

Ex. running the following code:

	st.execute("create table t1 (c clob)");
	PreparedStatement pSt = conn.prepareStatement(
		"insert into t1 values (?)");
	try {
		pSt.setNull(1, Types.VARCHAR);
		System.out.println("Error did NOT reproduce.");
	} catch (SQLException se) {
		System.out.println("Error reproduced:");

Against Derby embedded, the result will be:

   Error reproduced:
   SQL Exception: An attempt was made to get a data value of type 'CLOB' from a 
data value of type 'VARCHAR'.

But against the Network Server, everything works fine.  Derby embedded will work 
in other cases where compatible types are used (ex. using setNull() with 
Types.INTEGER for a BIGINT parameter), but fails for this particular situation. 
Thus I'm assuming this is _not_ intentional (i.e. that the above code should work).

Can anyone confirm one way or the other?  If I don't hear otherwise, I'll file a 
Jira issue tomorrow.


View raw message