From: | Jeremy Ferry <jferry(at)iexposure(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | idle in transaction - should I care? |
Date: | 2002-03-07 21:17:48 |
Message-ID: | 200203072117.g27LHmB10343@destiny.iexposure.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Hi all. I am new to PostgreSQL and JDBC so any help would be appreciated...
I've included some code that essentially represents a servlet that gets an
image from a PostgreSQL database. It appears that the transaction begins,
executes, and ends correctly but then starts another query. Where is that
last query comming from?
public void run( HttpPresentationComms comms ) throws
HttpPresentationException {
DBConnection conn = null;
try {
comms.response.setContentType( "image/jpg" );
conn = Enhydra.getDatabaseManager().allocateConnection();
conn.setAutoCommit( false );
ResultSet rs = conn.executeQuery(
"SELECT IMAGE_DATA FROM IMAGE WHERE IMAGE_ID = " +
comms.request.getParameter( "id" ) );
byte[] data = null;
if ( rs.next() ) {
data = rs.getBytes( source );
}
conn.commit();
conn.close();
comms.response.getOutputStream().write( data );
} catch ( Exception e ) {
try {
conn.rollback();
} catch ( SQLException sqle ) {
System.err.println( "ERROR rolling back" );
sqle.printStackTrace();
}
e.printStackTrace();
} finally {
if ( conn != null ) {
conn.release();
}
}
}
Below is what I find in the PostgreSQL log. Notice that the query executes
and commits then another query begins. Nothing else happens after this and
the process says "idle in transaction".
2002-03-07 14:56:16 DEBUG: query: begin
2002-03-07 14:56:16 DEBUG: ProcessUtility: begin
2002-03-07 14:56:16 DEBUG: query: SELECT IMAGE_DATA FROM IMAGE WHERE
IMAGE_ID = 1131
2002-03-07 14:56:16 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'
2002-03-07 14:56:16 DEBUG: query: commit
2002-03-07 14:56:16 DEBUG: ProcessUtility: commit
2002-03-07 14:56:16 DEBUG: query: begin
2002-03-07 14:56:16 DEBUG: ProcessUtility: begin
I have several questions about this: Am I doing something wrong? Is this
normal/expected behavior? Will it cause problems?
--
Jeremy Ferry
jferry(at)iexposure(dot)com
Internet Exposure Inc.
http://www.iexposure.com
(612) 676-1946 (ext 18)
Web Development - Web Marketing - ISP Services
From | Date | Subject | |
---|---|---|---|
Next Message | adr rrp pub | 2002-03-07 22:48:43 | PostgreSQL and MacOS X |
Previous Message | Dave Cramer | 2002-03-07 19:48:14 | Re: Can't find database driver |