I'm forwarding this to the jdbc list.


>Hi Peter,
>I am trying to insert and/or select from Postgres a gif image by using
>the Large Object type.   I am writing a Java client and middle tier to a
>Postgres db backend using your JDBC driver and I have hit an issue with
>what your documantation shows and the exceptions I am seeing when I run
>a simple comand line program.
>here is the java code I am running:
>   File file = new File("...(some path).../tomcat.gif");
>   FileInputStream fis = new FileInputStream(file);
>   PreparedStatement ps = db.prepareStatement("insert into image values
>   ps.setString(1,file.getName());
>   //ps.setObject(2,fis,java.sql.Types.LONGVARBINARY);
>   ps.setBinaryStream(2,fis, file.length());
>   ps.executeUpdate();
>   ps.close();
>   fis.close();
>The code is almost verbatim from your documentation.
>"image" is a table  containing a image name and oid attributes.  I have
>tried both the statements,  ps.setBinaryStream(2,fis, file.length())
>and  ps.setObject(2,fis,java.sql.Types.LONGVARBINARY).  The first
>statement produces a compile time error :
>main.java:70: setBinaryStream(int,java.io.InputStream,int) in
>java.sql.PreparedStatement cannot be applied to
>   ps.setBinaryStream(2,fis, file.length());
>The JDBC API confuses me a little.  Why doesn't the JDBC interface
>define a long for this argument?  After all, we are dealing with big
>byte streams.  Hmm.
>The second statement, ps.setObject(2,fis,java.sql.Types.LONGVARBINARY),
>which I thought would be a good substitute produces a runtime exception:
>Unknown Types value.
>  at
>  at
>  at main.main(main.java:69)
>Does your driver fully implement the JDBC API?  LONGVARBINARY  is a
>valiid java.sql data type.  Maybe I have an old version of your driver.
>Here is my environment:
>PostgreSQL 7.0.3 on i686-pc-linux-gnu, compiled by gcc 2.96
>java full version "1.4.0-beta2-b77"
>uname -a
>Linux localhost.localdomain 2.4.2-2 #1 Sun Apr 8 20:41:30 EDT 2001 i686
>Any help would be appreciated.  Thank you.
>Brian Buck

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to