Re: setNull on prepared statement not working?
It was the crack then...! I guess postgres and the as400 are just more forgiving thanx for the help. -jj- On Mon, 2005-02-07 at 15:11 -0800, Sunitha Kambhampati wrote: > Jeremiah Jahn wrote: > > > insertPreparedStatement.setNull(5,Types.NULL); where column is a > >timestamp column. > > > >This is with the latest official release(10.0.2.1). running on java 5 > >and linux. > > > > > Actually, if you are trying to set null on a column with type timestamp > , I think it should be > > insertPreparedStatement.setNull(5,Types.TIMESTAMP); > > http://java.sun.com/j2se/1.4.2/docs/api/java/sql/PreparedStatement.html#setNull(int,%20int) > > Hope this helps, > Sunitha. > > > > The truth is what is; what should be is a dirty lie. -- Lenny Bruce signature.asc Description: This is a digitally signed message part
Re: setNull on prepared statement not working?
>From a quick look at what you have posted, your setNull should look like >following insertPreparedStatement.setNull(5,Types.TIMESTAMP). If you look at java.sql.Types, you will see that Types.NULL is int 0 under the covers and the error you are getting is because Derby is trying to extract TIMESTAMP value from 0. Mamta Jeremiah Jahn wrote: > Am I on crack or shouldn't this work? > > insertPreparedStatement.setNull(5,Types.NULL); where column is a > timestamp column. > > This is with the latest official release(10.0.2.1). running on java 5 > and linux. > > SQL Exception: An attempt was made to get a data value of type 'TIMESTAMP' > from a data value of type '0'. > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java) > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java) > at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java) > at > org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(EmbedConnection.java) > at > org.apache.derby.impl.jdbc.ConnectionChild.newSQLException(ConnectionChild.java) > at > org.apache.derby.impl.jdbc.EmbedPreparedStatement.dataTypeConversion(EmbedPreparedStatement.java) > at > org.apache.derby.impl.jdbc.EmbedPreparedStatement.setNull(EmbedPreparedStatement.java) > at > com.goodinassociates.evidencetracking.functionaltests.DatabaseTestHelper.prepareEventTable(DatabaseTestHelper.java:383) > at > com.goodinassociates.evidencetracking.functionaltests.DatabaseTestHelper.prepareCaseEvidenceTable(DatabaseTestHelper.java:500) > at > com.goodinassociates.evidencetracking.main.MainControllerTest.testMain(MainControllerTest.java:40) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:585) > at junit.framework.TestCase.runTest(TestCase.java:154) > at junit.framework.TestCase.runBare(TestCase.java:127) > at junit.framework.TestResult$1.protect(TestResult.java:106) > at junit.framework.TestResult.runProtected(TestResult.java:124) > at junit.framework.TestResult.run(TestResult.java:109) > at junit.framework.TestCase.run(TestCase.java:118) > at junit.framework.TestSuite.runTest(TestSuite.java:208) > at junit.framework.TestSuite.run(TestSuite.java:203) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186) > > Be different: conform. > > > >Name: signature.asc >signature.asc Type: application/pgp-signature > Description: This is a digitally signed message part
Re: setNull on prepared statement not working?
Jeremiah Jahn wrote: insertPreparedStatement.setNull(5,Types.NULL); where column is a timestamp column. This is with the latest official release(10.0.2.1). running on java 5 and linux. Actually, if you are trying to set null on a column with type timestamp , I think it should be insertPreparedStatement.setNull(5,Types.TIMESTAMP); http://java.sun.com/j2se/1.4.2/docs/api/java/sql/PreparedStatement.html#setNull(int,%20int) Hope this helps, Sunitha.
Re: setNull on prepared statement not working?
Jeremiah Jahn wrote: >shouldn't this work? > > insertPreparedStatement.setNull(5,Types.NULL); where column is a >timestamp column. > > You would want to do it like this: insertPreparedStatement.setNull(5,Types.TIMESTAMP); The type should be the type of the column. Kathey
