pst.setNull(2, Types.BLOB)

Lists: pgsql-jdbc
From: Tore Halset <halset(at)pvv(dot)ntnu(dot)no>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: pst.setNull(2, Types.BLOB)
Date: 2005-02-16 12:05:31
Message-ID: 027c5113c2deb3202097bfb5617c5650@pvv.ntnu.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Hello.

I have just tried to upgrade my jdbc driver, but have a problem with
setNull for blobs. I am using postgresql-8.0-310.jdbc3.jar with
commons-dbcp-1.2.1.jar and postgresql-8.0.1.

The test table:
create table blobtest (a int primary key, b bytea);

Sql to reproduce the problem:
Connection conn = ...
PreparedStatement st = conn.prepareStatement("insert into
blobtest (a,b) values (?,?)");
st.setInt(1, 5);
st.setNull(2, Types.BLOB);
st.execute();
conn.commit();

Stacktrace:
org.postgresql.util.PSQLException: Unknown Types value.
at
org.postgresql.jdbc2.AbstractJdbc2Statement.setNull(AbstractJdbc2Stateme
nt.java:1003)
at
org.postgresql.jdbc3.AbstractJdbc3Statement.setNull(AbstractJdbc3Stateme
nt.java:1445)
at
org.apache.commons.dbcp.DelegatingPreparedStatement.setNull(DelegatingPr
eparedStatement.java:104)

Looks like AbstractJdbc2Statement are handling BINARY,VARBINARY and
LONGVARBINARY, but not BLOB. Is this a bug or should I not use
Types.BLOB?

Regards,
- Tore.


From: Kris Jurka <books(at)ejurka(dot)com>
To: Tore Halset <halset(at)pvv(dot)ntnu(dot)no>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: pst.setNull(2, Types.BLOB)
Date: 2005-02-17 03:21:06
Message-ID: Pine.BSO.4.56.0502162219090.25741@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Wed, 16 Feb 2005, Tore Halset wrote:

> I have just tried to upgrade my jdbc driver, but have a problem with
> setNull for blobs. I am using postgresql-8.0-310.jdbc3.jar with
> commons-dbcp-1.2.1.jar and postgresql-8.0.1.
>
> The test table:
> create table blobtest (a int primary key, b bytea);
>
> st.setNull(2, Types.BLOB);

This case did not work, and I've committed changes to cvs to make it work,
but not for the bytea case. BLOB implies using large objects, so it will
set type the null value as oid, not bytea. You should use one of the
binary types for bytea.

Kris Jurka