Re: LargeObject API

Lists: pgsql-jdbc
From: Dennis Thrysøe <dth(at)conscius(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: LargeObject API
Date: 2007-08-02 07:44:02
Message-ID: 46B18B42.2020709@conscius.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Hello,

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

I need to store (potentially) large chunks of data, so as I read the
documentation I need to use the oid type for performance reasons.

However, if the application is executing within a j2ee server with
connection pooling, the given Connection instance is just a proxy for
the actual one.

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

I'm not on the mailing list (yet).

-dennis
---------------------------------------------------------------------------
The information in this email is confidential and may be legally protected.


From: "Xavier Poinsard" <xpoinsard(at)free(dot)fr>
To: Dennis Thrysøe <dth(at)conscius(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: LargeObject API
Date: 2007-08-02 14:30:23
Message-ID: 46B1EA7F.7010003@free.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Hi,

You have to chose between database portability and better performance.
Personally I am using a BYTEA field and setBytes : this allows me to
have portable code across databases and decent performance.

Regards.

Dennis Thrysøe a écrit :
> Hello,
>
> Is there any way to use the proprietary LargeObject API, without
> actually having a reference to the postgresql Drivers's Connection object?
>
> I need to store (potentially) large chunks of data, so as I read the
> documentation I need to use the oid type for performance reasons.
>
> However, if the application is executing within a j2ee server with
> connection pooling, the given Connection instance is just a proxy for
> the actual one.
>
> Otherwise I could possibly use PreparedStatement.setBlob(), but how
> could I create a Blob instance?
>
> I'm not on the mailing list (yet).
>
> -dennis
> ---------------------------------------------------------------------------
> The information in this email is confidential and may be legally protected.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>


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
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


From: Dennis Thrysøe <dth(at)conscius(dot)com>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: LargeObject API
Date: 2007-08-03 06:54:30
Message-ID: 46B2D126.6070309@conscius.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Kris Jurka wrote:
> 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.

My goal is to support any j2ee server, so I cannot assume much about any
proxy/pooling mechanism.

> 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);

Thanks. That looks like a good solution.

-dennis
---------------------------------------------------------------------------
The information in this email is confidential and may be legally protected.