Retrieving bytes error(complete mail)!!

From: "FERNANDA M(dot)" <ferdim(at)yahoo(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Retrieving bytes error(complete mail)!!
Date: 2003-10-23 23:26:18
Message-ID: 20031023232618.70615.qmail@web13806.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)yahoo(dot)com
ferdim79(at)msn(dot)com

http://geocities.com/ferdim

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

Browse pgsql-jdbc by date

  From Date Subject
Next Message Nick Fankhauser 2003-10-24 21:30:08 Re: No suitable driver
Previous Message FERNANDA M. 2003-10-23 23:19:35 Retrieving bytes error!!