Example Code breaks. - Mailing list pgsql-jdbc

From john-paul delaney
Subject Example Code breaks.
Date
Msg-id Pine.LNX.4.21.0204290719520.5669-100000@justatest.com
Whole thread Raw
List pgsql-jdbc

 Hello List...

 I'm trying to setup a servlet that posts images to a postgres table.  Following the example code in the PostgreSQL
7.2.1Documentation (Chapter 8.6. Storing Binary Data) below I get an error: 

 setBinaryStream(int,java.io.InputStream,int) in java.sql.PreparedStatement cannot be applied to
(int,java.io.FileInputStream,long)
         ps.setBinaryStream(4, fis, file.length());
               ^
Seems there's a mismatch of data types between int and long of InputStream and FileInputStream of java.io?  How to cast
oneso it's type is compatible with the other? 

Thanks for any suggestions
/j-p.


 EXAMPLE CODE

 To insert an image, you would use:
   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();



-----------------------
 JUSTATEST Art Online
  www.justatest.com





pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: Updateable result set
Next
From: "Marin Dimitrov"
Date:
Subject: Re: Example Code breaks.