Re: Blobs
От | Thomas Kellerer |
---|---|
Тема | Re: Blobs |
Дата | |
Msg-id | frdqip$j67$1@ger.gmane.org обсуждение исходный текст |
Ответ на | Blobs ("Marc Horvath" <mhorv@comcast.net>) |
Список | pgsql-general |
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.setInt(1, 42), stmt.setBinaryStream(2, f, (int)f.length()); stmt.executeUpdate(); connection.commit(); Note that the field blob_table is defined as bytea in Postgres Regards Thomas
В списке pgsql-general по дате отправления: