Example Code breaks.

Поиск
Список
Период
Сортировка
От john-paul delaney
Тема Example Code breaks.
Дата
Msg-id Pine.LNX.4.21.0204290719520.5669-100000@justatest.com
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: Updateable result set
Следующее
От: "Marin Dimitrov"
Дата:
Сообщение: Re: Example Code breaks.