Re: Large Objects - Mailing list pgsql-jdbc

From Nils O. Selåsdal
Subject Re: Large Objects
Date
Msg-id 01072720440300.28877@space.net
Whole thread Raw
In response to Large Objects  (Daniel Fisher <dfisher@vt.edu>)
List pgsql-jdbc
On Friday 27 July 2001 16:59, Daniel Fisher wrote:
> I'm am attempting to make one of my Java servlets work with both MySQL &
> Postgres. I'm having some trouble inserting a large object into the
> database. I'm fairly certain that the problem is in my java code because I
> wrote some quick PHP code and it worked fine. The main problem is I'm not
> getting any errors, so I'm kinda stumped. The code appears to run fine, but
> nothing is being inserted into the database. Any help would be appreciated.
>
> ----- Here is my Java source -----
>
>     // getConnection gives me a database connection
>     // image is a byte[] passed to this function
>
>     Connection conn = null;
>     PreparedStatement pstmt = null;
>
>     try {
>
>       conn = getConnection();
>       conn.setAutoCommit(false);
>       pstmt = conn.prepareStatement("INSERT INTO dfisher (image) VALUES
> (?)"); pstmt.setBytes(1, image);
>       pstmt.executeUpdate();
>
>     } catch (Exception e) {
>       e.printStackTrace();
>     }
>     finally {
>       try { if (pstmt != null) pstmt.close(); } catch (Exception e) {
> e.printStackTrace(); } try { if (conn != null) conn.close(); } catch
> (Exception e) { e.printStackTrace(); } }
>   }
if you want to insert Large Objects, you need to use one of the setXXXStream
of the statement, not setBytes.

pgsql-jdbc by date:

Previous
From: Daniel Fisher
Date:
Subject: Re: Large Objects
Next
From: Tom Lane
Date:
Subject: Re: Large Objects