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.

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to