|| at Mar 14, 2008 at 12:20 pm
Marc Horvath, 14.03.2008 12:35:
I was wondering if anyone had any working sample code of inserting a
blob into a table and then retrieving one from a table for viewing?
I’m using Postgres 8.2, the jdbc is postgresql-8.2-504.jdbc3, and the
Java is 1.6.
I’m also running on a Windows XP Pro box if that matters.
You should probably have posted that to the JDBC mailing list.
I am using the following code successfully:
PreparedStatement stmt = connection.prepareStatement("insert into blob_table (id, blob_data) values (?,?)";
File f = new File("pretty_image.jpg");
FileInputStream f = new FileInputStream(f);
stmt.setBinaryStream(2, f, (int)f.length());
Note that the field blob_table is defined as bytea in Postgres