views:

45

answers:

1

I am not able to call setNull on PreparedStatement using MS Access (sun.jdbc.odbc.JdbcOdbcDriver)

preparedStatement.setNull(index, sqltype). Is there a workaround for this.

For LONGBINARY data type, I tried the following calls, neither worked.

 setNull(index, java.sql.Types.VARBINARY)
 setNull(index, java.sql.Types.BINARY)
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Invalid SQL data type
        at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)
        at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
        at sun.jdbc.odbc.JdbcOdbc.SQLBindInParameterNull(JdbcOdbc.java:986)
        at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setNull(JdbcOdbcPreparedStatement.java:363)

A: 

The Sun JDBC ODBC bridge driver has a lot of odd bugs/flaws and I personally have never used it extensively, so here's a shoot in the dark: what if you just set it with a real null?

preparedStatement.setBinaryStream(index, null);

For the better MS Access driver, have a look at HXTT.

BalusC
Thanks, setting real null did not work either.java.lang.AbstractMethodError: org.postgresql.jdbc3.Jdbc3PreparedStatement.setBinaryStream(ILjava/io/InputStream;)Vlooks like it is looking for a valid binary stream. I'll be checking out HXTT.
Firat
This error means that the method is not implemented in the ODBC bridge driver. Try `setBytes()` instead, or if in vain `setObject()`. The HXTT driver is excellent, it only costs a bit of $$$.
BalusC