db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <Knut.Hat...@Sun.COM>
Subject Re: 'VARCHAR' from a data value of type '0'
Date Tue, 04 Jul 2006 11:10:47 GMT
Eike Stepper <stepper@sympedia.com> writes:

> Hi,
>
> Does anybody know, why I get an SQLException if I try to insert a NULL value?
> I use embedded mode (db-derby-10.1.2.1-bin).
> On a windows system I created following table:
>
> CREATE TABLE CDO_CLASS (
> 	CID INTEGER NOT NULL,
> 	NAME VARCHAR(255) NOT NULL,
> 	PARENTNAME VARCHAR(255),
> 	TABLENAME VARCHAR(127) NOT NULL,
> 	PID INTEGER NOT NULL,
> 	CONSTRAINT CID_CDO_CLASS PRIMARY KEY (CID))
> CREATE UNIQUE INDEX CDO_CLASS_NAME ON CDO_CLASS (NAME)
> CREATE INDEX CDO_CLASS_PID ON CDO_CLASS (PID)
>
>
> This statement leads to the exception:
>
> [DEBUG] net4j.server.mapper: INSERT INTO CDO_CLASS VALUES (1, 'library.Library', NULL,
'LIBRARY', 1)
> Exception in thread "pool-1-thread-1" org.springframework.dao.DataIntegrityViolationException:
PreparedStatementCallback; SQL [INSERT INTO CDO_CLASS VALUES (?, ?, ?, ?, ?)]; An attempt
was made to get a data value of type 'VARCHAR' from a data value of type '0'.; nested exception
is org.apache.derby.impl.jdbc.EmbedSQLException: An attempt was made to get a data value of
type 'VARCHAR' from a data value of type '0'.
> SQL Exception: An attempt was made to get a data value of type 'VARCHAR' from a data
value of type '0'.
> 	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 Source)
> 	at org.apache.derby.impl.jdbc.ConnectionChild.newSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.dataTypeConversion(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.setNull(Unknown Source)
> 	at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:95)
[...]

It seems like setNull() is called with 0 as type id (second argument)
at line 95 in StatementCreatorUtils.java. It should work if you change
the type id to java.sql.Types.VARCHAR.

-- 
Knut Anders

Mime
View raw message