From: | Peter Mount <peter(at)retep(dot)org(dot)uk> |
---|---|
To: | anleon(at)ucab(dot)edu(dot)ve, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: JDBC: HELP!!! Can't Upload BLOBS on 6.5.3 |
Date: | 2000-10-03 11:16:57 |
Message-ID: | Pine.LNX.4.21.0010031210310.420-100000@maidast.demon.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Tue, 3 Oct 2000 pgsql-bugs(at)postgresql(dot)org wrote:
> Angel Leon (anleon(at)ucab(dot)edu(dot)ve) reports a bug with a severity of 1
> The lower the number the more severe it is.
>
> Short Description
> JDBC: HELP!!! Can't Upload BLOBS on 6.5.3
>
> Long Description At First I tried the PreparedStatement
> "setBinaryStream" to upload a jpeg.. but it turned out to be, they
> hadn't implemented that method... then I tried using the "setBytes"
> method... They both worked on SQL Server 7.0... but the last one
> (setBytes) returns the following Exception:
>
> FastPath protocol error: Z It just won't upload bytes... do I have to
> use the "lo_import" function within my SQL statement... I'm
> programming in Java I guess I don't need dat. Is it that the driver is
> too old? Can I use a 7.x JDBC Driver?
Does the ImageViewer example included with the source work? It shows two
methods of loading an image into a BLOB.
Here's from the source:
// fetch the large object manager
LargeObjectManager lom = ((org.postgresql.Connection)db).getLargeObjectAPI();
db.setAutoCommit(false);
// A temporary buffer - this can be as large as you like
byte buf[] = new byte[2048];
// Open the file
FileInputStream fis = new FileInputStream(new File(dir,name));
// Now create the large object
int oid = lom.create();
LargeObject blob = lom.open(oid);
// Now copy the file into the object.
//
// Note: we dont use write(buf), as the last block is rarely the same
// size as our buffer, so we have to use the amount read.
int s,t=0;
while((s=fis.read(buf,0,buf.length))>0) {
t+=s;
blob.write(buf,0,s);
}
// Close the object
blob.close();
The 7.x Driver should work. If not, the 7.0 source does include the
correct 6.5.3 source (it didn't get released with 6.5.3 due to me messing
up the cvs commit :-( )
> PLEASE POSTGRESQL PEOPLE I NEED AN ANSWER!!! I COULD LOOSE MY
> JOB OVER THIS.
Also, you are using transactions (see the setAutoCommit(false) above)?
Peter
--
Peter T Mount peter(at)retep(dot)org(dot)uk http://www.retep.org.uk
PostgreSQL JDBC Driver http://www.retep.org.uk/postgres/
Java PDF Generator http://www.retep.org.uk/pdf/
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Smith | 2000-10-03 17:00:35 | pg_dump 7.0.2 fails on linuxppc |
Previous Message | Jerome Alet | 2000-10-03 07:22:39 | Re: grant/revoke bug with delete/update |