Thread: JDBC Interface Using Large Objects

JDBC Interface Using Large Objects

From
tjm2@mail.ikasths.dk (Troels Jegbjaerg Moerch)
Date:
Hi
 
I am using the JDBC 7.0-1.2 driver, PostgreSQL 7.02 Database and JDK 1.3 on Linux Red Hat 7.0. Almost everything works great. But when I am trying to insert a file into my postgresql database I get this error:
 
SQLException: InputStream as parameter not supported
Here is my code:
 
   File file = new File(theFile);
   FileInputStream fis = new FileInputStream(file);

   PreparedStatement ps = con.prepareStatement("insert into music(ID,
BinaryData) values (?,?)");
   ps.setString(1,1);
   ps.setBinaryStream(2,fis,(int)file.length());
   ps.execute();
   ps.close();
   fis.close();
The exception is thrown in this line:
 
ps.setBinaryStream(2,fis,(int)file.length());
Anybody know what is wrong?
 
TJM