Re: LargeObject API

From: Kris Jurka <books(at)ejurka(dot)com>
To: Dennis Thrysøe <dth(at)conscius(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: LargeObject API
Date: 2007-08-02 17:09:27
Message-ID: Pine.BSO.4.64.0708021304160.14791@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Thu, 2 Aug 2007, Dennis Thrysøe wrote:

> Is there any way to use the proprietary LargeObject API, without actually
> having a reference to the postgresql Drivers's Connection object?

Often connection wrappers provide a means to access the underlying
Connection. You don't say what you're using so you'll have to consult
those docs yourself.

> Otherwise I could possibly use PreparedStatement.setBlob(), but how could I
> create a Blob instance?
>

JDBC4 provides a means for creating Blobs, but we haven't implemented that
yet, so the easiest way is to create a Blob is to get it from the
database:

stmt.execute("CREATE TABLE t (a int, b oid)");
stmt.execute("INSERT INTO t VALUES (1, lo_creat(-1))");
ResultSet rs = stmt.executeQuery("SELECT b FROM t WHERE a = 1");
rs.next();
Blob b = rs.getBlob(1);

Kris Jurka

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dennis Thrysøe 2007-08-03 06:54:30 Re: LargeObject API
Previous Message Kris Jurka 2007-08-02 17:02:38 Re: statement caching patch from Laszlo Hornyak for review