Posted By:
Aleksandr_Stserbakov
Posted On:
Tuesday, February 12, 2002 02:39 AM
I have a table with fields of different types (binary(16), varchar, datetime etc). I want to insert NULL into the field with the datetime type. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection connect = DriverManager.getConnection("jdbc:odbc:DB", "sa", ""); PreparedStatement stmt = connect.prepareStatement("INSERT INTO LINKS (oid, startdate) values (?, ?)"); stmt.setBytes(1, new byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}); stmt.setNull(2, java.sql.Types.TIMESTAMP); // this line doesn't work and I am getting an exception: Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC D
More>>
I have a table with fields of different types (binary(16), varchar, datetime etc).
I want to insert NULL into the field with the datetime type.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connect = DriverManager.getConnection("jdbc:odbc:DB", "sa", "");
PreparedStatement stmt = connect.prepareStatement("INSERT INTO LINKS (oid, startdate) values (?, ?)");
stmt.setBytes(1, new byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0});
stmt.setNull(2, java.sql.Types.TIMESTAMP); // this line doesn't work
and I am getting an exception:
Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC Driver Manager] SQL data type out of
range
I have tried to use java.sql.Types.DATE but with the same effect.
What do I have to do ?
Thanks.
<<Less