Re: BUG #3278: PSQLException when using setBinaryStream via JDBC

Lists: pgsql-bugs
From: "jeffrey zhao" <jeffrey(dot)zhao(at)metalogic-inc(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #3278: PSQLException when using setBinaryStream via JDBC
Date: 2007-05-14 16:02:42
Message-ID: 200705141602.l4EG2g70011058@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 3278
Logged by: jeffrey zhao
Email address: jeffrey(dot)zhao(at)metalogic-inc(dot)com
PostgreSQL version: 8.2.4-1
Operating system: Windows XP
Description: PSQLException when using setBinaryStream via JDBC
Details:

When I run the following program, I got an exception as following:

File file = new File("myimage.gif");
FileInputStream fis = new FileInputStream(file);
PreparedStatement ps = conn.prepareStatement("INSERT INTO images VALUES (?,
?)");
ps.setString(1, file.getName());
ps.setBinaryStream(2, fis, file.length());
ps.executeUpdate();
ps.close();
fis.close();

Exception:

org.postgresql.util.PSQLException: Method
org.postgresql.jdbc4.Jdbc4PreparedStat
ement.setBinaryStream(int, InputStream, long) is not yet implemented.
at org.postgresql.Driver.notImplemented(Driver.java:728)
at
org.postgresql.jdbc4.AbstractJdbc4Statement.setBinaryStream(AbstractJ
dbc4Statement.java:70)

Is the method setBinaryStream really not yet implemented?

Thanks.


From: Kris Jurka <books(at)ejurka(dot)com>
To: jeffrey zhao <jeffrey(dot)zhao(at)metalogic-inc(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3278: PSQLException when using setBinaryStream via JDBC
Date: 2007-05-14 18:29:12
Message-ID: Pine.BSO.4.64.0705141426500.20137@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Mon, 14 May 2007, jeffrey zhao wrote:

> The following bug has been logged online:
>
> Bug reference: 3278
>
> When I run the following program, I got an exception as following:
>
> ps.setBinaryStream(2, fis, file.length());
> org.postgresql.util.PSQLException: Method
> org.postgresql.jdbc4.Jdbc4PreparedStat
> ement.setBinaryStream(int, InputStream, long) is not yet implemented.
>
> Is the method setBinaryStream really not yet implemented?
>

JDBC4 added a setBinaryStream(int, InputStream, long) method which has not
been implemented yet. JDBC2 offers setBinaryStream(int, InputStream, int)
which is implmented. So you'll need to cast the last parameter to an
integer to make it work with the current driver.

Kris Jurka