The following bug has been logged online:
Bug reference: 1780
Logged by: Andrus Adamchik
Email address: andrus@objectstyle.org
PostgreSQL version: 8.0.1
Operating system: Mac OS X 10.4
Description: JDBC driver "setNull" throws for BLOB and CLOB columns
Details:
Whenver I call PreparedStatement.setNull(int, int) on BLOB or CLOB columns,
an exception below occurs. Driver version: postgresql-8.0-310.jdbc3.jar. But
looks like latest CVS version has the same problem.
Test case:
Driver d = new org.postgresql.Driver();
Properties p = new Properties();
p.put("user", "andrus");
p.put("password", "andrus");
Connection c =
d.connect("jdbc:postgresql://localhost:5432/cayenne", p);
PreparedStatement st = c
.prepareStatement("insert into BLOB_TEST (BLOB_TEST_ID,
BLOB_COL) values (?, ?)");
st.setInt(1, 1);
// this is the line where it blows:
st.setNull(2, Types.BLOB);
Stack trace:
org.postgresql.util.PSQLException: Unknown Types value.
at
org.postgresql.jdbc2.AbstractJdbc2Statement.setNull(AbstractJdbc2Statement.j
ava:1003)
at
org.postgresql.jdbc3.AbstractJdbc3Statement.setNull(AbstractJdbc3Statement.j
ava:1445)
at NullBlob.main(NullBlob.java:24)