Thread: Large Objects

Large Objects

From
Daniel Fisher
Date:
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.postgresql.Driver@e08d1172]
getConnection returning driver[className=org.postgresql.Driver,org.postgresql.Driver@e08d1172]
Large Object initialised


--
Daniel Fisher

RE: Large Objects

From
PERIN Pascal
Date:
Hi,

You should verify that you are in a transactionnal mode ie this line might
appear :
myConnection.setAutoCommit(false);

If not, you problem might be solved.
Hope this helps
Pascal

-------------------------------
Pascal PERIN
SESAM - Chargé de mission
Tel :  33 1 47 15 49 66
Fax : 33 1 47 15 49 75
http://www.sesam.org
-------------------------------

> -----Message d'origine-----
> De:    Daniel Fisher [SMTP:dfisher@vt.edu]
> Date:    vendredi 27 juillet 2001 18:00
> À:    pgsql-jdbc@postgresql.org
> Objet:    [JDBC] Large Objects
>
> 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.postgresql.Driver@e08d1172]
> getConnection returning
> driver[className=org.postgresql.Driver,org.postgresql.Driver@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

RE: Large Objects

From
PERIN Pascal
Date:
Have a look at this :
http://www.fr.postgresql.org/devel-corner/docs/postgres/jdbc-lo.html

-------------------------------
Pascal PERIN
SESAM - Chargé de mission
Tel :  33 1 47 15 49 66
Fax : 33 1 47 15 49 75
http://www.sesam.org
-------------------------------

> -----Message d'origine-----
> De:    Daniel Fisher [SMTP:dfisher@vt.edu]
> Date:    vendredi 27 juillet 2001 18:00
> À:    pgsql-jdbc@postgresql.org
> Objet:    [JDBC] Large Objects
>
> 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.postgresql.Driver@e08d1172]
> getConnection returning
> driver[className=org.postgresql.Driver,org.postgresql.Driver@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

Re: Large Objects

From
Philip Crotwell
Date:
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.postgresql.Driver@e08d1172]
> getConnection returning driver[className=org.postgresql.Driver,org.postgresql.Driver@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@seis.sc.edu
------------------------------------------------------------------------



Re: Large Objects

From
Daniel Fisher
Date:
Yeah that line is in my code.
See the source below.

--
Daniel Fisher


On Friday 27 July 2001 12:13, you wrote:
> Hi,
>
> You should verify that you are in a transactionnal mode ie this line might
> appear :
> myConnection.setAutoCommit(false);
>
> If not, you problem might be solved.
> Hope this helps
> Pascal
>
> -------------------------------
> Pascal PERIN
> SESAM - Chargé de mission
> Tel :  33 1 47 15 49 66
> Fax : 33 1 47 15 49 75
> http://www.sesam.org
> -------------------------------
>
> > -----Message d'origine-----
> > De:    Daniel Fisher [SMTP:dfisher@vt.edu]
> > Date:    vendredi 27 juillet 2001 18:00
> > À:    pgsql-jdbc@postgresql.org
> > Objet:    [JDBC] Large Objects
> >
> > 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?use
> >r =dfisher&password=dfisher")
> >     trying
> > driver[className=org.postgresql.Driver,org.postgresql.Driver@e08d1172]
> > getConnection returning
> > driver[className=org.postgresql.Driver,org.postgresql.Driver@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

Re: Large Objects

From
Daniel Fisher
Date:
I tried that but I got the same results.

--
Daniel Fisher


On Friday 27 July 2001 12:36, you wrote:
> 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?use
> >r=dfisher&password=dfisher") trying
> > driver[className=org.postgresql.Driver,org.postgresql.Driver@e08d1172]
> > getConnection returning
> > driver[className=org.postgresql.Driver,org.postgresql.Driver@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@seis.sc.edu
> ------------------------------------------------------------------------

Re: Large Objects

From
"Nils O. Selåsdal"
Date:
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.

Re: Large Objects

From
Tom Lane
Date:
Daniel Fisher <dfisher@vt.edu> writes:
> 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.

The query trace shows that you are starting a transaction (with BEGIN)
and never committing it (no COMMIT or END).  So when you close the
connection, the transaction is rolled back, and its effects go away.

I suppose that having done "conn.setAutoCommit(false)", you need to add
a command to explicitly commit the transaction, but I don't know JDBC
well enough to know how you do that...

            regards, tom lane

RE: Large Objects

From
"Dave Cramer"
Date:
Yes, you have to commit the transaction at the end

Con.commit(), or con.rollback() I think.

Dave
-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Tom Lane
Sent: July 29, 2001 4:20 PM
To: daniel.fisher@vt.edu
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] Large Objects


Daniel Fisher <dfisher@vt.edu> writes:
> 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.

The query trace shows that you are starting a transaction (with BEGIN)
and never committing it (no COMMIT or END).  So when you close the
connection, the transaction is rolled back, and its effects go away.

I suppose that having done "conn.setAutoCommit(false)", you need to add
a command to explicitly commit the transaction, but I don't know JDBC
well enough to know how you do that...

            regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster



RE: Large Objects

From
Kovács Péter
Date:
This would be the standard way of inserting Large Objects. But last time I
looked at it, it did not work with the jdbc implementation provided with
pgsql.

-----Original Message-----
From: Nils O. Selåsdal [mailto:noselasd@frisurf.no]
Sent: Friday, July 27, 2001 9:44 PM
To: daniel.fisher@vt.edu; Daniel Fisher; pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] Large Objects

if you want to insert Large Objects, you need to use one of the setXXXStream

of the statement, not setBytes.


RE: Large Objects

From
"chris markiewicz"
Date:
i have a different but related question - i OCCASIONALLY get a fastpath
error.  i'd guess that it shows up once in every hundred LO requests.  i've
verified that autocommit is set to false.  the stack trace is shown here:

FastPath call returned ERROR:  lo_tell: invalid large object descriptor (0)

    at org.postgresql.fastpath.Fastpath.fastpath(Fastpath.java:141)
    at org.postgresql.fastpath.Fastpath.fastpath(Fastpath.java:191)
    at org.postgresql.fastpath.Fastpath.getInteger(Fastpath.java:203)
    at org.postgresql.largeobject.LargeObject.tell(LargeObject.java:232)
    at org.postgresql.largeobject.LargeObject.size(LargeObject.java:247)
    at org.postgresql.jdbc2.ResultSet.getBytes(ResultSet.java:370)
    at org.postgresql.jdbc2.ResultSet.getBytes(ResultSet.java:580)
    at (the rest is from my code)...

any thoughts?

thanks
chris

-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Kovács Péter
Sent: Monday, July 30, 2001 3:12 AM
To: noselasd@frisurf.no; daniel.fisher@vt.edu; Daniel Fisher;
pgsql-jdbc@postgresql.org
Subject: RE: [JDBC] Large Objects


This would be the standard way of inserting Large Objects. But last time I
looked at it, it did not work with the jdbc implementation provided with
pgsql.

-----Original Message-----
From: Nils O. Selåsdal [mailto:noselasd@frisurf.no]
Sent: Friday, July 27, 2001 9:44 PM
To: daniel.fisher@vt.edu; Daniel Fisher; pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] Large Objects

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 majordomo@postgresql.org


errors while getting large objects...

From
"chris markiewicz"
Date:
hello.

my application uses large objects frequently...to render the main page, it
might load anywhere from zero to 10 large objects - mostly images or
documents.  recently i started stress testing this page (making it always
load many LOs) and i frequently encounter two different problems.

1. fastpath - autocommit is always false...i've verified this several times.
my current workaround is to catch the fastpath error and resubmit the
query...usually works on the second pass and rarely makes it to 4 passes
(the current limit i have set).  i have included a stack trace at the bottom
of this message.  does anyone have any ideas on this?  i'm using 7.0.2 with
the 7.0-1.2 jdbc driver.  the occurences seem totally random...sometimes a
page loads perfectly, sometimes i get three fastpath errors...sometimes the
first load gets FP erros, sometimes the fifth page does.

2. hanging - i recently noticed that the processing sometimes (pretty
frequently) hangs on the line of code that grabs the LO from the db...i've
tried both:

byte[] bytes = rs.getBytes(columnName);
 and
InputStream is = rs.getBinaryStream(columnName);

Same result for both.  It hangs indefinitely.  Similar to the fastpath -
sometimes it happens, sometimes it doesn't...but it always happens within 5
screen loads of my stress test page.

does anyone know if these problems were fixed in recent versions of
postgresql?  is anyone having similar problems?  i greatly appreciate any
help!

thanks
chris






FastPath call returned ERROR:  lo_tell: invalid large object descriptor (0)

    at org.postgresql.fastpath.Fastpath.fastpath(Fastpath.java:141)
    at org.postgresql.fastpath.Fastpath.fastpath(Fastpath.java:191)
    at org.postgresql.fastpath.Fastpath.getInteger(Fastpath.java:203)
    at org.postgresql.largeobject.LargeObject.tell(LargeObject.java:232)
    at org.postgresql.largeobject.LargeObject.size(LargeObject.java:247)
    at org.postgresql.jdbc2.ResultSet.getBytes(ResultSet.java:370)
    at org.postgresql.jdbc2.ResultSet.getBinaryStream(ResultSet.java:514)
    at org.postgresql.jdbc2.ResultSet.getBinaryStream(ResultSet.java:616)
    at
com.commnav.sbh.framework.persist.JDBCEngine.loadResultSet(JDBCEngine.java:4
40)
    at com.commnav.sbh.framework.persist.JDBCEngine.load(JDBCEngine.java:284)
    at
com.commnav.sbh.framework.persist.PersistenceObject.load(PersistenceObject.j
ava:169)
    at
com.commnav.sbh.framework.documentmanager.SBHDocument.loadComplex(SBHDocumen
t.java:586)
    at
com.commnav.sbh.framework.persist.PersistenceObject.load(PersistenceObject.j
ava:208)
    at
com.commnav.sbh.applications.documentmanager.FavoriteDocumentIteratorTag.doS
tartTag(FavoriteDocumentIteratorTag.java:56)
    at
apps.favorited_00025cuments._0002fapps_0002ffavoritedocuments_0002ffavorited
ocumentspidget_0002ejspfavoritedocumentspidget_jsp_24._jspService(_0002fapps
_0002ffavoritedocuments_0002ffavoritedocumentspidget_0002ejspfavoritedocumen
tspidget_jsp_24.java:392)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
va:177)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
    at org.apache.tomcat.core.Handler.service(Handler.java:286)
    at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
    at
org.apache.tomcat.facade.RequestDispatcherImpl.include(RequestDispatcherImpl
.java:345)
    at
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:414)
    at
_0002fdesktop_0002ejspdesktop_jsp_130._jspService(_0002fdesktop_0002ejspdesk
top_jsp_130.java:601)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
va:177)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
    at org.apache.tomcat.core.Handler.service(Handler.java:286)
    at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
    at
org.apache.tomcat.facade.RequestDispatcherImpl.forward(RequestDispatcherImpl
.java:194)
    at
com.commnav.sbh.framework.navigation.handlers.NavigationHandlerImpl.execute(
NavigationHandlerImpl.java:39)
    at
com.commnav.sbh.framework.navigation.Navigator.navigate(Navigator.java:80)
    at com.commnav.sbh.servlets.ControlServlet.doPost(ControlServlet.java:132)
    at com.commnav.sbh.servlets.ControlServlet.doGet(ControlServlet.java:63)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
    at org.apache.tomcat.core.Handler.service(Handler.java:286)
    at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
    at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
    at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
    at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:210)
    at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
    at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
    at java.lang.Thread.run(Thread.java:484)


hangs while getting large objects...

From
"chris markiewicz"
Date:
hello.  i occasionally have problems getting large objects from postgres.  i
am confident that this problem is a problem with my code and not postgres
because i cannot find similar complaints and no one responded to my question
from earlier this month (appears later in this email).

I have a screen that loads several LOs (small images, mostly).  Occasionally
the process hangs on the rs.getBytes() line.  Does anyone know what could be
causing this?

Separately, I have written a simple program that queries the table with the
LOs.  No problems - unless I run it while my application is hanging (then
the simple program hangs indefinitely as well).  I am able to run queries
from the command line while this is going on, so it seems like the byte
stream is plugging things up, but everything else is fine.

Does anyone have any ideas what the problem could be?  Everything works
perfectly 90% of the time, but 90% isn't that good.  At this point, I'm not
even sure what to try.  Are there any Postgres configuration changes I could
make?  Would Postgres logging tell me anything.

I greatly appreciate your help.  note - i'm running 7.0.3 on
linux...connecting through jdbc.

chris



-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of chris markiewicz
Sent: Thursday, August 02, 2001 6:04 PM
To: cmarkiew@commnav.com; pgsql-jdbc@postgresql.org
Subject: [JDBC] errors while getting large objects...


hello.

my application uses large objects frequently...to render the main page, it
might load anywhere from zero to 10 large objects - mostly images or
documents.  recently i started stress testing this page (making it always
load many LOs) and i frequently encounter two different problems.

1. fastpath - autocommit is always false...i've verified this several times.
my current workaround is to catch the fastpath error and resubmit the
query...usually works on the second pass and rarely makes it to 4 passes
(the current limit i have set).  i have included a stack trace at the bottom
of this message.  does anyone have any ideas on this?  i'm using 7.0.2 with
the 7.0-1.2 jdbc driver.  the occurences seem totally random...sometimes a
page loads perfectly, sometimes i get three fastpath errors...sometimes the
first load gets FP erros, sometimes the fifth page does.

2. hanging - i recently noticed that the processing sometimes (pretty
frequently) hangs on the line of code that grabs the LO from the db...i've
tried both:

byte[] bytes = rs.getBytes(columnName);
 and
InputStream is = rs.getBinaryStream(columnName);

Same result for both.  It hangs indefinitely.  Similar to the fastpath -
sometimes it happens, sometimes it doesn't...but it always happens within 5
screen loads of my stress test page.

does anyone know if these problems were fixed in recent versions of
postgresql?  is anyone having similar problems?  i greatly appreciate any
help!

thanks
chris






FastPath call returned ERROR:  lo_tell: invalid large object descriptor (0)

    at org.postgresql.fastpath.Fastpath.fastpath(Fastpath.java:141)
    at org.postgresql.fastpath.Fastpath.fastpath(Fastpath.java:191)
    at org.postgresql.fastpath.Fastpath.getInteger(Fastpath.java:203)
    at org.postgresql.largeobject.LargeObject.tell(LargeObject.java:232)
    at org.postgresql.largeobject.LargeObject.size(LargeObject.java:247)
    at org.postgresql.jdbc2.ResultSet.getBytes(ResultSet.java:370)
    at org.postgresql.jdbc2.ResultSet.getBinaryStream(ResultSet.java:514)
    at org.postgresql.jdbc2.ResultSet.getBinaryStream(ResultSet.java:616)
    at
com.commnav.sbh.framework.persist.JDBCEngine.loadResultSet(JDBCEngine.java:4
40)
    at com.commnav.sbh.framework.persist.JDBCEngine.load(JDBCEngine.java:284)
    at
com.commnav.sbh.framework.persist.PersistenceObject.load(PersistenceObject.j
ava:169)
    at
com.commnav.sbh.framework.documentmanager.SBHDocument.loadComplex(SBHDocumen
t.java:586)
    at
com.commnav.sbh.framework.persist.PersistenceObject.load(PersistenceObject.j
ava:208)
    at
com.commnav.sbh.applications.documentmanager.FavoriteDocumentIteratorTag.doS
tartTag(FavoriteDocumentIteratorTag.java:56)
    at
apps.favorited_00025cuments._0002fapps_0002ffavoritedocuments_0002ffavorited
ocumentspidget_0002ejspfavoritedocumentspidget_jsp_24._jspService(_0002fapps
_0002ffavoritedocuments_0002ffavoritedocumentspidget_0002ejspfavoritedocumen
tspidget_jsp_24.java:392)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
va:177)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
    at org.apache.tomcat.core.Handler.service(Handler.java:286)
    at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
    at
org.apache.tomcat.facade.RequestDispatcherImpl.include(RequestDispatcherImpl
.java:345)
    at
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:414)
    at
_0002fdesktop_0002ejspdesktop_jsp_130._jspService(_0002fdesktop_0002ejspdesk
top_jsp_130.java:601)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
va:177)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
    at org.apache.tomcat.core.Handler.service(Handler.java:286)
    at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
    at
org.apache.tomcat.facade.RequestDispatcherImpl.forward(RequestDispatcherImpl
.java:194)
    at
com.commnav.sbh.framework.navigation.handlers.NavigationHandlerImpl.execute(
NavigationHandlerImpl.java:39)
    at
com.commnav.sbh.framework.navigation.Navigator.navigate(Navigator.java:80)
    at com.commnav.sbh.servlets.ControlServlet.doPost(ControlServlet.java:132)
    at com.commnav.sbh.servlets.ControlServlet.doGet(ControlServlet.java:63)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
    at org.apache.tomcat.core.Handler.service(Handler.java:286)
    at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
    at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
    at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
    at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:210)
    at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
    at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
    at java.lang.Thread.run(Thread.java:484)


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org


Re: hangs while getting large objects...

From
Rene Pijlman
Date:
On Wed, 15 Aug 2001 15:04:21 -0400, you wrote:
>i am confident that this problem is a problem with my code and not postgres

OK, so where is your code? A small isolated test case that
reproduces the problem would be best.

Since this appears to be JDBC-specific I did not cc
pgsql-general.

Regards,
René Pijlman

RE: hangs while getting large objects...

From
"Dave Cramer"
Date:
Chris,

Try using the latest jar files from http://jdbc.fastcrypt.com

DAve

-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of chris markiewicz
Sent: August 15, 2001 3:04 PM
To: pgsql-jdbc@postgresql.org; pgsql-general@postgresql.org
Cc: chris.markiewicz@commnav.com
Subject: [JDBC] hangs while getting large objects...


hello.  i occasionally have problems getting large objects from
postgres.  i am confident that this problem is a problem with my code
and not postgres because i cannot find similar complaints and no one
responded to my question from earlier this month (appears later in this
email).

I have a screen that loads several LOs (small images, mostly).
Occasionally the process hangs on the rs.getBytes() line.  Does anyone
know what could be causing this?

Separately, I have written a simple program that queries the table with
the LOs.  No problems - unless I run it while my application is hanging
(then the simple program hangs indefinitely as well).  I am able to run
queries from the command line while this is going on, so it seems like
the byte stream is plugging things up, but everything else is fine.

Does anyone have any ideas what the problem could be?  Everything works
perfectly 90% of the time, but 90% isn't that good.  At this point, I'm
not even sure what to try.  Are there any Postgres configuration changes
I could make?  Would Postgres logging tell me anything.

I greatly appreciate your help.  note - i'm running 7.0.3 on
linux...connecting through jdbc.

chris



-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of chris markiewicz
Sent: Thursday, August 02, 2001 6:04 PM
To: cmarkiew@commnav.com; pgsql-jdbc@postgresql.org
Subject: [JDBC] errors while getting large objects...


hello.

my application uses large objects frequently...to render the main page,
it might load anywhere from zero to 10 large objects - mostly images or
documents.  recently i started stress testing this page (making it
always load many LOs) and i frequently encounter two different problems.

1. fastpath - autocommit is always false...i've verified this several
times. my current workaround is to catch the fastpath error and resubmit
the query...usually works on the second pass and rarely makes it to 4
passes (the current limit i have set).  i have included a stack trace at
the bottom of this message.  does anyone have any ideas on this?  i'm
using 7.0.2 with the 7.0-1.2 jdbc driver.  the occurences seem totally
random...sometimes a page loads perfectly, sometimes i get three
fastpath errors...sometimes the first load gets FP erros, sometimes the
fifth page does.

2. hanging - i recently noticed that the processing sometimes (pretty
frequently) hangs on the line of code that grabs the LO from the
db...i've tried both:

byte[] bytes = rs.getBytes(columnName);
 and
InputStream is = rs.getBinaryStream(columnName);

Same result for both.  It hangs indefinitely.  Similar to the fastpath -
sometimes it happens, sometimes it doesn't...but it always happens
within 5 screen loads of my stress test page.

does anyone know if these problems were fixed in recent versions of
postgresql?  is anyone having similar problems?  i greatly appreciate
any help!

thanks
chris






FastPath call returned ERROR:  lo_tell: invalid large object descriptor
(0)

    at org.postgresql.fastpath.Fastpath.fastpath(Fastpath.java:141)
    at org.postgresql.fastpath.Fastpath.fastpath(Fastpath.java:191)
    at
org.postgresql.fastpath.Fastpath.getInteger(Fastpath.java:203)
    at
org.postgresql.largeobject.LargeObject.tell(LargeObject.java:232)
    at
org.postgresql.largeobject.LargeObject.size(LargeObject.java:247)
    at org.postgresql.jdbc2.ResultSet.getBytes(ResultSet.java:370)
    at
org.postgresql.jdbc2.ResultSet.getBinaryStream(ResultSet.java:514)
    at
org.postgresql.jdbc2.ResultSet.getBinaryStream(ResultSet.java:616)
    at
com.commnav.sbh.framework.persist.JDBCEngine.loadResultSet(JDBCEngine.ja
va:4
40)
    at
com.commnav.sbh.framework.persist.JDBCEngine.load(JDBCEngine.java:284)
    at
com.commnav.sbh.framework.persist.PersistenceObject.load(PersistenceObje
ct.j
ava:169)
    at
com.commnav.sbh.framework.documentmanager.SBHDocument.loadComplex(SBHDoc
umen
t.java:586)
    at
com.commnav.sbh.framework.persist.PersistenceObject.load(PersistenceObje
ct.j
ava:208)
    at
com.commnav.sbh.applications.documentmanager.FavoriteDocumentIteratorTag
.doS
tartTag(FavoriteDocumentIteratorTag.java:56)
    at
apps.favorited_00025cuments._0002fapps_0002ffavoritedocuments_0002ffavor
ited
ocumentspidget_0002ejspfavoritedocumentspidget_jsp_24._jspService(_0002f
apps
_0002ffavoritedocuments_0002ffavoritedocumentspidget_0002ejspfavoritedoc
umen
tspidget_jsp_24.java:392)
    at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServle
t.ja
va:177)
    at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
    at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
    at org.apache.tomcat.core.Handler.service(Handler.java:286)
    at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
    at
org.apache.tomcat.facade.RequestDispatcherImpl.include(RequestDispatcher
Impl
.java:345)
    at
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:4
14)
    at
_0002fdesktop_0002ejspdesktop_jsp_130._jspService(_0002fdesktop_0002ejsp
desk
top_jsp_130.java:601)
    at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServle
t.ja
va:177)
    at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
    at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
    at org.apache.tomcat.core.Handler.service(Handler.java:286)
    at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
    at
org.apache.tomcat.facade.RequestDispatcherImpl.forward(RequestDispatcher
Impl
.java:194)
    at
com.commnav.sbh.framework.navigation.handlers.NavigationHandlerImpl.exec
ute(
NavigationHandlerImpl.java:39)
    at
com.commnav.sbh.framework.navigation.Navigator.navigate(Navigator.java:8
0)
    at
com.commnav.sbh.servlets.ControlServlet.doPost(ControlServlet.java:132)
    at
com.commnav.sbh.servlets.ControlServlet.doGet(ControlServlet.java:63)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
    at org.apache.tomcat.core.Handler.service(Handler.java:286)
    at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
    at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.jav
a:79
7)
    at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
    at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(H
ttpC
onnectionHandler.java:210)
    at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416
)
    at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:49
8)
    at java.lang.Thread.run(Thread.java:484)


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster



RE: hangs while getting large objects...

From
"chris markiewicz"
Date:
While I can readily reproduce it on my application, I have so far been
unsuccessful at writing a test case that reproduces the problem.

Oh, I just tried the latest drivers - no luck - same problem.

Equally unfortunate is the fact that all database processing is heavily
abstracted in the application - so there is no method that grabs a
connection, performs the query, iterates through the ResultSet, and closes
the rs/stmt/conn.  I know that I am unlikely to find help unless I can
manage to reproduce the problem on an independent program, but I was hoping
that there might be some general LO or byte stream rule that I am not
following.

The area where is breaks is shown below.  The method grabs the column name
from RS metadata and calls either getObject or getBytes.  When it hangs, it
occurs on the getBytes(...) line.
Once it hangs, the system is essentially useless.  My test program will
freeze when it reaches the particular row that the application is trying to
access.  The application hangs on to the commection until I stop Tomcat.

I'll continue trying to reproduce in a separate program.

thanks
chris

if (sqlf.getGetType().equals("byte[]")) {
    try {
          System.out.println("JDBCE.getbytes (before)");
            byte[] bytes = rs.getBytes(columnName);
            System.out.println("JDBCE.getbytes (after)");
            marshaller.setObjectField(o, sqlf.getMapField(), bytes);
      } catch (Exception e) {
          String exStr = e.toString();
            //## create SBHException here so that it is logged
            SBHException sbhex = new SBHException(e);
            if (exStr.indexOf("FastPath") == -1) {
             System.out.println("JDBCE.lrs NONFastPath error..."+exStr);
                  throw e;
            } else {
                  System.out.println("JDBCE.lrs FastPath error..."+exStr);
                  throw new FastPathException(e);
            }
    }
} else {
    result = rs.getObject(columnName);
      marshaller.setObjectField(o, sqlf.getMapField(), result);
}