Retrieving bytes error(complete mail)!! - Mailing list pgsql-jdbc

From FERNANDA M.
Subject Retrieving bytes error(complete mail)!!
Date
Msg-id 20031023232618.70615.qmail@web13806.mail.yahoo.com
Whole thread Raw
List pgsql-jdbc
Hello! i have  problem when retrieving a byte array
from postgres.

I'm saving a file (open office) with the following
code...

FileInputStream fis = new
FileInputStream(doc.getFile());
length = (doc.getFile()).length();
PreparedStatement ps = connection.prepareStatement
                                   ("INSERT INTO
documents VALUES (?, ?, ?, ?)");
            ps.setInt(1, doc.getDocumentId());
            ps.setString(2, doc.getFileName());
            ps.setDate(3, new
java.sql.Date(System.currentTimeMillis()));
ps.setBinaryStream(4, fis, (int) length);
            ps.close();



But when i'm trying to retrieve the document i get the
following error:

Connection is closed.  Operation is not permitted.
        at
org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:480)
        at
org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:461)
        at
org.postgresql.jdbc1.AbstractJdbc1Connection.getSQLType(AbstractJdbc1Connection.java:1271)
        at
org.postgresql.jdbc1.AbstractJdbc1Connection.getPGType(AbstractJdbc1Connection.java:1335)
        at
org.postgresql.Field.getPGType(Field.java:93)
        at
org.postgresql.jdbc1.AbstractJdbc1ResultSet.getBytes(AbstractJdbc1ResultSet.java:196)
        at
org.postgresql.jdbc1.AbstractJdbc1ResultSet.getBinaryStream(AbstractJdbc1ResultSet.java:318)



I'm trying to get the data with this method from the
result set...
is  = rs.getBinaryStream(1);
                    is.read(docBytes);

and the error is exactly in the rs.getBinaryStream(1);

Does anybody knows why i get this strange error.

Thank you!
Fernanda




=====
.................... F E R D I ............................
Les choses simples sont les plus extraordinaires,
et seuls les savants parviennent � les voir...L'Alchimiste

ferdim@yahoo.com
ferdim79@msn.com

http://geocities.com/ferdim

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

pgsql-jdbc by date:

Previous
From: "FERNANDA M."
Date:
Subject: Retrieving bytes error!!
Next
From: "Mike Kenny - CPX Mngd Services"
Date:
Subject: No suitable driver