Re: Large Objects

From: Philip Crotwell <crotwell(at)seis(dot)sc(dot)edu>
To: daniel(dot)fisher(at)vt(dot)edu
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Large Objects
Date: 2001-07-27 16:36:04
Message-ID: Pine.GSO.4.10.10107271233440.27071-100000@tigger.seis.sc.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


You probably need to add a conn.commit(); statement after the
executeUpdate.

Philip

On Fri, 27 Jul 2001, 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(); }
> }
> }
>
>
> ----- Here is my Postgres log -----
>
> /usr/local/bin/postmaster: BackendStartup: pid 54277 user dfisher db dfisher socket 8
> FindExec: found "/usr/local/bin/postgres" using argv[0]
> 2001-07-27 11:51:35 [54277] DEBUG: connection: host=127.0.0.1 user=dfisher database=dfisher
> 2001-07-27 11:51:35 [54277] DEBUG: StartTransactionCommand
> 2001-07-27 11:51:35 [54277] DEBUG: query: set datestyle to 'ISO'; select getdatabaseencoding()
> 2001-07-27 11:51:35 [54277] DEBUG: ProcessUtility: set datestyle to 'ISO'; select getdatabaseencoding()
> 2001-07-27 11:51:35 [54277] DEBUG: CommitTransactionCommand
> 2001-07-27 11:51:35 [54277] DEBUG: StartTransactionCommand
> 2001-07-27 11:51:35 [54277] DEBUG: query: begin
> 2001-07-27 11:51:35 [54277] DEBUG: ProcessUtility: begin
> 2001-07-27 11:51:35 [54277] DEBUG: CommitTransactionCommand
> 2001-07-27 11:51:35 [54277] DEBUG: StartTransactionCommand
> 2001-07-27 11:51:35 [54277] DEBUG: query: SET TRANSACTION ISOLATION LEVEL READ COMMITTED
> 2001-07-27 11:51:35 [54277] DEBUG: ProcessUtility: SET TRANSACTION ISOLATION LEVEL READ COMMITTED
> 2001-07-27 11:51:35 [54277] DEBUG: CommitTransactionCommand
> 2001-07-27 11:51:35 [54277] DEBUG: StartTransactionCommand
> 2001-07-27 11:51:35 [54277] DEBUG: query: select proname, oid from pg_proc where proname = 'lo_open' or proname = 'lo_close' or proname = 'lo_creat' or proname = 'lo_unlink' or proname = 'lo_lseek' or proname = 'lo_tell' or proname = 'loread'
> or proname = 'lowrite'
> 2001-07-27 11:51:35 [54277] DEBUG: CommitTransactionCommand
> 2001-07-27 11:51:35 [54277] DEBUG: StartTransactionCommand
> 2001-07-27 11:51:35 [54277] DEBUG: CommitTransactionCommand
> 2001-07-27 11:51:35 [54277] DEBUG: StartTransactionCommand
> 2001-07-27 11:51:35 [54277] DEBUG: CommitTransactionCommand
> 2001-07-27 11:51:35 [54277] DEBUG: StartTransactionCommand
> 2001-07-27 11:51:35 [54277] DEBUG: CommitTransactionCommand
> 2001-07-27 11:51:35 [54277] DEBUG: StartTransactionCommand
> 2001-07-27 11:51:35 [54277] DEBUG: CommitTransactionCommand
> 2001-07-27 11:51:35 [54277] DEBUG: StartTransactionCommand
> 2001-07-27 11:51:35 [54277] DEBUG: query: INSERT INTO dfisher (image) VALUES (19291)
> 2001-07-27 11:51:35 [54277] DEBUG: CommitTransactionCommand
> /usr/local/bin/postmaster: reaping dead processes...
> /usr/local/bin/postmaster: CleanupProc: pid 54277 exited with status 0
>
> ----- Here is my JServ log -----
>
> DriverManager.getConnection("jdbc:postgresql://localhost:5432/dfisher?user=dfisher&password=dfisher")
> trying driver[className=org.postgresql.Driver,org(dot)postgresql(dot)Driver(at)e08d1172]
> getConnection returning driver[className=org.postgresql.Driver,org(dot)postgresql(dot)Driver(at)e08d1172]
> Large Object initialised
>
>
> --
> Daniel Fisher
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>

------------------------------------------------------------------------
Philip Crotwell (803)777-0955 (803)777-0906 fax crotwell(at)seis(dot)sc(dot)edu
------------------------------------------------------------------------

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Daniel Fisher 2001-07-27 16:48:41 Re: Large Objects
Previous Message PERIN Pascal 2001-07-27 16:17:51 RE: Large Objects