JDBC: HELP!!! Can't Upload BLOBS on 6.5.3

From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: JDBC: HELP!!! Can't Upload BLOBS on 6.5.3
Date: 2000-10-03 05:25:46
Message-ID: 200010030525.e935PkV17699@hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Angel Leon (anleon(at)ucab(dot)edu(dot)ve) reports a bug with a severity of 1
The lower the number the more severe it is.

Short Description
JDBC: HELP!!! Can't Upload BLOBS on 6.5.3

Long Description
At First I tried the PreparedStatement "setBinaryStream" to upload a jpeg.. but it turned out to be, they hadn't implemented that method... then I tried using the "setBytes" method... They both worked on SQL Server 7.0... but the last one (setBytes) returns the following Exception:

FastPath protocol error: Z
It just won't upload bytes... do I have to use the "lo_import" function within my SQL statement... I'm programming in Java I guess I don't need dat. Is it that the driver is too old? Can I use a 7.x JDBC Driver?

PLEASE POSTGRESQL PEOPLE I NEED AN ANSWER!!! I COULD LOOSE MY JOB OVER THIS.

Sample Code
/** This works perfectly on SQL Server JTurbo JDBC Driver...*/
public boolean uploadImage(File file,int picId)
{
try
{
FileInputStream fis = new FileInputStream(file);

byte[] b = new byte[fis.available()];
fis.read(b);

PreparedStatement ps = rut._con.prepareStatement(
"insert into PICS values (?,?)");
ps.setInt(1,picId);
ps.setBytes(2,b);
ps.executeUpdate();
ps.close();
fis.close();
}
catch(IOException ioexx)
{
System.out.println("=========IOException=================");
System.out.println(ioexx + "//\n");
out2.println(ioexx + "//\n");
ioexx.toString();
System.out.println("=====================================");
return false;
}
catch(SQLException e)
{
System.out.println("File Upload Exception: " + e.getMessage());
out2.println("<font color=red>SQL Upload Exception:</font> " + e.getMessage());
return false;
};
return true;
}

No file was uploaded with this report

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jerome Alet 2000-10-03 07:22:39 Re: grant/revoke bug with delete/update
Previous Message Tom Lane 2000-10-03 04:51:07 Re: Strong feeling of something ugly lurking deeply within 7.0 ;-)