Re: Large Object

From: Paul Thomas <paul(at)tmsl(dot)demon(dot)co(dot)uk>
To: "pgsql-jdbc (at) postgresql (dot) org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Large Object
Date: 2003-09-04 12:36:44
Message-ID: 20030904133644.A17198@bacon
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


On 04/09/2003 10:44 Andreas Bauer wrote:
> Hi,
>
> I don't want to annoy anyone, but I just can't write a large object.
> Code:
> File file = null;
> FileInputStream fis = null;
> try{file = new File("c:/testen/test.pdf");
> fis = new FileInputStream(file);}catch(Exception e){e.printStackTrace();}
> try{
> dat.openDB();
> dat.db.setAutoCommit(false);
> PreparedStatement ps = dat.db.prepareStatement("INSERT INTO blob_test
> VALUES
> (?, ?)");
> ps.setString(1, file.getName());
> ps.setBinaryStream(2, fis, (int)file.length());
> ps.executeUpdate();
> System.out.println(ps.toString()); // shows: INSERT INTO blob_test VALUES
> ('test.pdf, 390368)
> ps.close();}catch(Exception e){e.printStackTrace();}
> fis.close();
>
> The table looks like this:
>
> CREATE TABLE blob_test (
> name varchar(35),
> pdf oid
> );

Your table definition is for use withe the Large Object storage mechanism
but your code is for storing binary data in a bytea column.

--
Paul Thomas
+------------------------------+---------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for the Smaller
Business |
| Computer Consultants |
http://www.thomas-micro-systems-ltd.co.uk |
+------------------------------+---------------------------------------------+

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Toby Doig 2003-09-04 14:26:18 Re: Large Object
Previous Message Paul Thomas 2003-09-04 12:18:18 Re: Large Object - Error found