JDBC PostgreSQhelL

From: <acshafer(at)moon(dot)hec(dot)utah(dot)edu>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: JDBC PostgreSQhelL
Date: 2001-10-17 23:40:58
Message-ID: Pine.LNX.4.10.10110171714430.17226-100000@moon.hec.utah.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

I'm a getting a bit flustered with my old friend Postgresql. Everything
was fine and dandy until I decided I needed to use large objects.

At first, after following the documentation, I was getting InputStream not
supported as a parameter. I started looking around and found some things
in the archives that said streams aren't supported until version 7.1. (the
fact that the documentation gives an example using streams to use large
objects going at least back to 6.5 is lame, why not just add a note that
this isn't implemented? Wouldn't that save the most headaches?) Ok, no
problem, I'm running 7.0, I can upgrade to 7.1. After wrestling the RPMs
into submission, finally got 7.1.3 up and running. Ok, need new drivers
now, ok, no problems, add them to the classpath and. . . now I'm getting
some new funk:

java.sql.SQLException: ERROR: oidin: error in ". . . a big long string
representing the file. . . ": can't parse " . . .same big long string,
again. . ."

at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:88)
at org.postgresql.Connection.ExecSQL(Connection.java:356)
. . .

Here is the gist of the code (should look pretty familiar, it's straight
out of the documentation):

File file = new File("mytest.blob");
FileInputStream fis = new FileInputStream(file);
PreparedStatement ps = con.prepareStatement("insert into blobtest
values (?,?)");
ps.setString(1, file.getName());
ps.setUnicodeStream(2, fis, (int)file.length());
ps.executeUpdate();

Can I get a little direction? Any idea why I'm getting this error or how
to make it go away?

I would appreciate if anyone could supply an example or two of working
code, inserting and recalling files from the db using JDBC. I would
prefer to avoid the LargeObjectManager if possible, but if any one would
care to supply an example of code doing the same thing the
org.postgresql.largeobject package, I'd like to look through that also.

Also, Is there a javadoc of all the packages in the .jar file for
postgres?

Sincerely,

Andrew

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Bruce Momjian 2001-10-18 00:00:31 Re: Ant configuration
Previous Message Marko Kreen 2001-10-17 23:27:45 Re: [PATCHES] Ant configuration