-
1. Re: Unfinished local transaction was rolled back
kconner Dec 17, 2006 2:49 PM (in response to bvegso)It looks like you have not terminated one of your connections by calling rollback or commit.
-
2. Re: Unfinished local transaction was rolled back
bvegso Dec 17, 2006 3:40 PM (in response to bvegso)private String[] getFilterSessions(String uid) { Log.infomsg(this, "Getting filter session list [UID: "+uid+"]"); String SQL="SELECT ..."; PreparedStatement pstmt = null; try { conn = OracleHelper.vchConnectionFromPool(); pstmt = conn.prepareStatement( SQL ); ResultSet rs=pstmt.executeQuery(); ... } catch (Exception ex) { ex.printStackTrace(); } finally { try { if( pstmt != null ) pstmt.close(); conn.close(); } catch (Exception e) { Log.errmsg( "Exception: " + e.getMessage() ); } }
getting connection with: (USE_CONNECTION_POOL() returns true)public static Connection vchConnectionFromPool() throws java.sql.SQLException, javax.naming.NamingException { if( USE_CONNECTION_POOL() ) { InitialContext initCtx = new InitialContext(); String JNDIName = "java:/jdbc/" + DB_CONNECTION_POOL(); DataSource src = (DataSource) initCtx.lookup( JNDIName ); return src.getConnection(); }
result:2006-12-17 21:18:29,549 INFO [STDOUT] 2: [xxx.xxx.xxx.Bean]: Getting filter session list [UID: asd-asda-sdasa333]
2006-12-17 21:18:29,552 DEBUG [org.jboss.resource.connectionmanager.TxConnectionManager] Unfinished local transaction was rolled back.org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener@74f8f156[state=NORMAL mc=org.jboss.resource.adapter.jdbc.local.LocalManagedConnection@793a2cd7 handles=0 lastUse=1166386709549 permit=true trackByTx=false mcp=org.jboss.resource.connectionmanager.JBossManagedConnectionPool$OnePool@5a56156e context=org.jboss.resource.connectionmanager.InternalManagedConnectionPool@49991717 xaResource=org.jboss.resource.connectionmanager.TxConnectionManager$LocalXAResource@61bb0cc0 txSync=null]
if i do a commit/rollback before conn.close() in the finally block, the result is:You cannot rollback with autocommit set!
from j2se doc: (http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Connection.html)Note: By default a Connection object is in auto-commit mode, which means that it automatically commits changes after executing each statement.
-
3. Re: Unfinished local transaction was rolled back
bvegso Dec 17, 2006 3:41 PM (in response to bvegso)i'm sorry i forgot to say i'm very thankful for your quick reply, and really apreciate your help! i was in such a hurry.
thanks again! -
4. Re: Unfinished local transaction was rolled back
kconner Dec 17, 2006 5:27 PM (in response to bvegso)Yes, that is correct. By default all connections opened in a non transactional context will have auto commit set to true.
However, you should only be seeing this error from a connection which has had its auto commit set to false. -
5. Re: Unfinished local transaction was rolled back
bvegso Dec 17, 2006 6:02 PM (in response to bvegso)thanks for your help. fortunately your comments made me think of my code in a new way and for some reason i tried to set autocommit to true with every retrieval of this connection object (in vchConnectionFromPool()).
this did help.
possible reason i think is that this method is static and always returns the same connection reference, which - if previously used in a transaction - was set to autocommit false.
i dont know if this makes sense, but whatever: the problem is solved.
thanks for hints, advice and help.