JDBC Interface Using Large Objects

From: tjm2(at)mail(dot)ikasths(dot)dk (Troels Jegbjaerg Moerch)
To: <pgsql-interfaces(at)postgresql(dot)org>
Subject: JDBC Interface Using Large Objects
Date: 2000-09-28 07:54:21
Message-ID: 002901c02921$500af990$97bfedd4@pc4151
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

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

Browse pgsql-interfaces by date

  From Date Subject
Next Message Jens Carlberg 2000-09-28 09:21:03 Re: Newlines in String inserts with JDBC
Previous Message Friedman, Eric 2000-09-28 00:33:58 RE: Newlines in String inserts with JDBC