RE: [INTERFACES] JDBC:Using Large Objects

From: Peter Mount <petermount(at)it(dot)maidstone(dot)gov(dot)uk>
To: "'Steffen Zimmert'" <szimmert(at)crcg(dot)edu>, PostgreSQL General Mailing List <pgsql-general(at)hub(dot)org>, pgsql-interfaces(at)postgreSQL(dot)org
Subject: RE: [INTERFACES] JDBC:Using Large Objects
Date: 1999-06-22 16:27:54
Message-ID: 1B3D5E532D18D311861A00600865478C9FCD@exchange1.nt.maidstone.gov.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-interfaces

The large object code has been working for some time now, however not
all of the stream methods work fully.

The best thing is to look at the blobtest and ImageViewer examples in
the src/interfaces/jdbc/example directory, as they show what methods are
currently supported.

Peter

--
Peter Mount
Enterprise Support
Maidstone Borough Council
Any views stated are my own, and not those of Maidstone Borough Council.

-----Original Message-----
From: Steffen Zimmert [mailto:szimmert(at)crcg(dot)edu]
Sent: Tuesday, June 22, 1999 7:38 PM
To: PostgreSQL General Mailing List; pgsql-interfaces(at)postgreSQL(dot)org
Subject: [INTERFACES] JDBC:Using Large Objects

Hi,

I am trying to store some Java objects in the PostgreSQL database
system. The version of PostgreSQL is 6.4.2 running on a linux sparc
machine. The JDBC driver is the one I found in the src/interfaces/jdbc
directory.

First of all I tried to use the example provided on page 167 of the JDCB
interface guide but the setBinaryStream() method is not supported by the
driver yet. So I wanted to store the objects as an array of bytes.
Here's the code I am using at the moment:

I created the associated database table with the following statement:
create table images (imgname name, imgoid oid);

// Load the driver
Class.forName("postgresql.Driver");

// Connect to database
System.out.println("Connecting to Database URL = " + url);
db = DriverManager.getConnection(url, usr, pwd);

System.out.println("Connected...Now creating a statement");
TestObject testObject = new TestObject(1);
byte[] objBytes = objectToBytes(testObject);
System.out.println("Bytes: " + objBytes.length);

// Create PreparedStatement
PreparedStatement ps = db.prepareStatement("Insert into database values
(?,?)");
ps.setString(1,"TEST");
ps.setBytes(2,objBytes);
ps.executeUpdate();
ps.close();

Every time when I execute my little program I receive the following
exception:
PostgreSQL basic test v6.3 rev 1
Connecting to Database URL = jdbc:postgresql://hornbill/foo
Connected...Now creating a statement
Bytes: 42
Exception caught.
java.sql.SQLException: IOError while reading from backend:
java.io.IOException: The backend has broken the connection. Possibly the
action you have attempted has caused it to close.
java.sql.SQLException: IOError while reading from backend:
java.io.IOException: The backend has broken the connection. Possibly the
action you have attempted has caused it to close.
at postgresql.PG_Stream.ReceiveChar(PG_Stream.java:183)
at postgresql.fastpath.Fastpath.fastpath(Compiled Code)
at postgresql.fastpath.Fastpath.fastpath(Fastpath.java:185)
at
postgresql.largeobject.LargeObject.write(LargeObject.java:147)
at
postgresql.PreparedStatement.setBytes(PreparedStatement.java:295)
at basic.<init>(basic.java:45)
at basic.main(basic.java:107)

In general is it possible to use the LargeObject interface with the JDBC
driver or is it not supported yet????
--
Best Regards,
Steffen Zimmert

Steffen Zimmert
Fraunhofer Center for Research in Computer Graphics
Providence, Rhode Island, USA
email: szimmert(at)crcg(dot)edu

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dinesh Patil 1999-06-22 18:18:10 Unsubscribe me for Postgres mailing list.
Previous Message Herouth Maoz 1999-06-22 16:03:42 Re: JDBC:Using Large Objects

Browse pgsql-interfaces by date

  From Date Subject
Next Message David Warnock 1999-06-22 16:45:34 Re: [INTERFACES] JDBC and character sets
Previous Message selkovjr 1999-06-22 16:08:09 Re: [INTERFACES] esql\c documentation