Received: from pain.crcg.edu (pain.crcg.edu [207.252.32.124]) by hub.org (8.9.3/8.9.3) with ESMTP id LAA59843 for ; Tue, 22 Jun 1999 11:42:35 -0400 (EDT) (envelope-from szimmert@crcg.edu) Received: from crcg.edu (wheel.crcg.edu [207.252.32.136]) by pain.crcg.edu (8.9.1b+Sun/8.9.1) with ESMTP id LAA14826; Tue, 22 Jun 1999 11:39:42 -0400 (EDT) Message-ID: <376FD814.23CE0333@crcg.edu> Disposition-Notification-To: Steffen Zimmert Date: Tue, 22 Jun 1999 11:38:12 -0700 From: Steffen Zimmert Organization: Fraunhofer CRCG, Inc. X-Mailer: Mozilla 4.61 [en] (WinNT; I) X-Accept-Language: en MIME-Version: 1.0 To: PostgreSQL General Mailing List , pgsql-interfaces@postgreSQL.org Subject: JDBC:Using Large Objects Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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.(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@crcg.edu