You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by dj...@apache.org on 2005/01/26 05:23:16 UTC
svn commit: r126463 - in incubator/derby/code/trunk/java/engine/org/apache/derby: impl/jdbc jdbc
Author: djd
Date: Tue Jan 25 20:23:14 2005
New Revision: 126463
URL: http://svn.apache.org/viewcvs?view=rev&rev=126463
Log:
Move methods from EmbedConnection20 into EmbedConnection
and remove the class EmbedConnection20. Cleanup for JSR169 support.
Removed:
incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection20.java
Modified:
incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection30.java
incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver20.java
incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java
incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAConnection.java
incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java
incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/XATransactionState.java
Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java?view=diff&rev=126463&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java&r1=126462&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java&r2=126463
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java Tue Jan 25 20:23:14 2005
@@ -2,7 +2,7 @@
Derby - Class org.apache.derby.impl.jdbc.EmbedConnection
- Copyright 1997, 2004 The Apache Software Foundation or its licensors, as applicable.
+ Copyright 1997, 2005 The Apache Software Foundation or its licensors, as applicable.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -41,6 +41,7 @@
import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
import org.apache.derby.iapi.sql.execute.ExecutionContext;
import org.apache.derby.iapi.sql.dictionary.DataDictionary;
+import org.apache.derby.iapi.store.access.XATransactionController;
/* can't import due to name overlap:
import java.sql.Connection;
@@ -75,13 +76,17 @@
* synchronized across all connections stemming from the
* same root connection. The synchronization is upon
* the a synchronized object return by the rootConnection.
+ <P><B>Supports</B>
+ <UL>
+ <LI> JDBC 2.0
+ </UL>
*
* @author djd
*
* @see TransactionResourceImpl
*
*/
-public abstract class EmbedConnection implements java.sql.Connection
+public class EmbedConnection implements java.sql.Connection
{
private static final StandardException exceptionClose = StandardException.closeException();
@@ -1686,6 +1691,117 @@
getLanguageConnection().setDrdaID(drdaID);
}
+ /**
+ Reset the connection before it is returned from a PooledConnection
+ to a new application request (wrapped by a BrokeredConnection).
+ Examples of reset covered here is dropping session temporary tables
+ and reseting IDENTITY_VAL_LOCAL.
+ Most JDBC level reset is handled by calling standard java.sql.Connection
+ methods from EmbedPooledConnection.
+ */
+ public void resetFromPool() throws SQLException {
+ synchronized (getConnectionSynchronization())
+ {
+ setupContextStack();
+ try {
+ getLanguageConnection().resetFromPool();
+ } catch (StandardException t) {
+ throw handleException(t);
+ }
+ finally
+ {
+ restoreContextStack();
+ }
+ }
+ }
+
+ /*
+ ** methods to be overridden by subimplementations wishing to insert
+ ** their classes into the mix.
+ ** The reason we need to override them is because we want to create a
+ ** Local20/LocalStatment object (etc) rather than a Local/LocalStatment
+ ** object (etc).
+ */
+
+
+ /*
+ ** XA support
+ */
+
+ public final int xa_prepare() throws SQLException {
+
+ synchronized (getConnectionSynchronization())
+ {
+ setupContextStack();
+ try
+ {
+ XATransactionController tc =
+ (XATransactionController) getLanguageConnection().getTransactionExecute();
+
+ int ret = tc.xa_prepare();
+
+ if (ret == XATransactionController.XA_RDONLY)
+ {
+ // On a prepare call, xa allows an optimization that if the
+ // transaction is read only, the RM can just go ahead and
+ // commit it. So if store returns this read only status -
+ // meaning store has taken the liberty to commit already - we
+ // needs to turn around and call internalCommit (without
+ // committing the store again) to make sure the state is
+ // consistent. Since the transaction is read only, there is
+ // probably not much that needs to be done.
+
+ getLanguageConnection().internalCommit(false /* don't commitStore again */);
+ }
+ return ret;
+ } catch (StandardException t)
+ {
+ throw handleException(t);
+ }
+ finally
+ {
+ restoreContextStack();
+ }
+ }
+ }
+
+
+ public final void xa_commit(boolean onePhase) throws SQLException {
+
+ synchronized (getConnectionSynchronization())
+ {
+ setupContextStack();
+ try
+ {
+ getLanguageConnection().xaCommit(onePhase);
+ } catch (StandardException t)
+ {
+ throw handleException(t);
+ }
+ finally
+ {
+ restoreContextStack();
+ }
+ }
+ }
+ public final void xa_rollback() throws SQLException {
+
+ synchronized (getConnectionSynchronization())
+ {
+ setupContextStack();
+ try
+ {
+ getLanguageConnection().xaRollback();
+ } catch (StandardException t)
+ {
+ throw handleException(t);
+ }
+ finally
+ {
+ restoreContextStack();
+ }
+ }
+ }
/**
* returns false if there is an underlying transaction and that transaction
* has done work. True if there is no underlying transaction or that
Deleted: /incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection20.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection20.java?view=auto&rev=126462
==============================================================================
Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection30.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection30.java?view=diff&rev=126463&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection30.java&r1=126462&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection30.java&r2=126463
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection30.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection30.java Tue Jan 25 20:23:14 2005
@@ -2,7 +2,7 @@
Derby - Class org.apache.derby.impl.jdbc.EmbedConnection30
- Copyright 2001, 2004 The Apache Software Foundation or its licensors, as applicable.
+ Copyright 2001, 2005 The Apache Software Foundation or its licensors, as applicable.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -53,10 +53,10 @@
a new class java.sql.Savepoint, which is referenced by java.sql.Connection.
</UL>
*
- * @see org.apache.derby.impl.jdbc.EmbedConnection20
+ * @see org.apache.derby.impl.jdbc.EmbedConnection
*
*/
-public class EmbedConnection30 extends EmbedConnection20
+public class EmbedConnection30 extends EmbedConnection
{
//////////////////////////////////////////////////////////
Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver20.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver20.java?view=diff&rev=126463&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver20.java&r1=126462&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver20.java&r2=126463
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver20.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver20.java Tue Jan 25 20:23:14 2005
@@ -2,7 +2,7 @@
Derby - Class org.apache.derby.jdbc.Driver20
- Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable.
+ Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -101,12 +101,7 @@
*/
public Connection getNewNestedConnection(EmbedConnection conn)
{
- if (SanityManager.DEBUG)
- {
- SanityManager.ASSERT(conn instanceof EmbedConnection20,
- "conn expected to be instanceof EmbedConnection20");
- }
- return new EmbedConnection20(conn);
+ return new EmbedConnection(conn);
}
/*
@@ -117,7 +112,7 @@
throws SQLException
{
// make a new local connection with a new transaction resource
- return new EmbedConnection20(this, url, info);
+ return new EmbedConnection(this, url, info);
}
/**
Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java?view=diff&rev=126463&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java&r1=126462&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java&r2=126463
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java Tue Jan 25 20:23:14 2005
@@ -2,7 +2,7 @@
Derby - Class org.apache.derby.jdbc.EmbedPooledConnection
- Copyright 2001, 2004 The Apache Software Foundation or its licensors, as applicable.
+ Copyright 2001, 2005 The Apache Software Foundation or its licensors, as applicable.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@
/* import impl class */
import org.apache.derby.impl.jdbc.Util;
-import org.apache.derby.impl.jdbc.EmbedConnection20;
+import org.apache.derby.impl.jdbc.EmbedConnection;
import org.apache.derby.iapi.jdbc.BrokeredConnection;
import org.apache.derby.iapi.jdbc.BrokeredConnectionControl;
@@ -59,7 +59,7 @@
private Vector eventListener; // who wants to know I am closed or error
- protected EmbedConnection20 realConnection;
+ protected EmbedConnection realConnection;
protected int defaultIsolationLevel;
private boolean defaultReadOnly;
protected BrokeredConnection currentConnectionHandle;
@@ -144,7 +144,7 @@
// first time we establish a connection
Connection rc = dataSource.getConnection(username, password, requestPassword);
- this.realConnection = (EmbedConnection20) rc;
+ this.realConnection = (EmbedConnection) rc;
defaultIsolationLevel = rc.getTransactionIsolation();
defaultReadOnly = rc.isReadOnly();
if (currentConnectionHandle != null)
Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAConnection.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAConnection.java?view=diff&rev=126463&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAConnection.java&r1=126462&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAConnection.java&r2=126463
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAConnection.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAConnection.java Tue Jan 25 20:23:14 2005
@@ -2,7 +2,7 @@
Derby - Class org.apache.derby.jdbc.EmbedXAConnection
- Copyright 2003, 2004 The Apache Software Foundation or its licensors, as applicable.
+ Copyright 2003, 2005 The Apache Software Foundation or its licensors, as applicable.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@
import org.apache.derby.iapi.store.access.xa.XAResourceManager;
import org.apache.derby.iapi.store.access.XATransactionController;
import org.apache.derby.impl.jdbc.Util;
-import org.apache.derby.impl.jdbc.EmbedConnection20;
+import org.apache.derby.impl.jdbc.EmbedConnection;
import org.apache.derby.impl.jdbc.TransactionResourceImpl;
import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.jdbc.ResourceAdapter;
@@ -347,7 +347,7 @@
if (tranState.isPrepared)
throw new XAException(XAException.XAER_PROTO);
- EmbedConnection20 conn = tranState.conn;
+ EmbedConnection conn = tranState.conn;
try {
@@ -451,7 +451,7 @@
if (tranState.isPrepared == onePhase)
throw new XAException(XAException.XAER_PROTO);
- EmbedConnection20 conn = tranState.conn;
+ EmbedConnection conn = tranState.conn;
try {
@@ -902,7 +902,7 @@
tranState.associationState = XATransactionState.TC_COMPLETED;
tranState.notifyAll();
- EmbedConnection20 conn = tranState.conn;
+ EmbedConnection conn = tranState.conn;
// already set in its own resource
// or can it be returned to its original resource?
@@ -959,7 +959,7 @@
Close an underlying connection object when there is
no active XAResource to hand it to.
*/
- private static void closeUnusedConnection(EmbedConnection20 conn) {
+ private static void closeUnusedConnection(EmbedConnection conn) {
if (conn != null) {
try {
conn.close();
Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java?view=diff&rev=126463&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java&r1=126462&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java&r2=126463
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java Tue Jan 25 20:23:14 2005
@@ -2,7 +2,7 @@
Derby - Class org.apache.derby.jdbc.XAStatementControl
- Copyright 2003, 2004 The Apache Software Foundation or its licensors, as applicable.
+ Copyright 2003, 2005 The Apache Software Foundation or its licensors, as applicable.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@
import org.apache.derby.iapi.jdbc.BrokeredStatement;
import org.apache.derby.iapi.jdbc.BrokeredPreparedStatement;
import org.apache.derby.iapi.jdbc.BrokeredCallableStatement;
-import org.apache.derby.impl.jdbc.EmbedConnection20;
+import org.apache.derby.impl.jdbc.EmbedConnection;
import org.apache.derby.impl.jdbc.EmbedStatement;
import org.apache.derby.impl.jdbc.EmbedPreparedStatement;
@@ -43,7 +43,7 @@
private final EmbedXAConnection xaConnection;
private final BrokeredConnection applicationConnection;
BrokeredStatement applicationStatement;
- private EmbedConnection20 realConnection;
+ private EmbedConnection realConnection;
private Statement realStatement;
private PreparedStatement realPreparedStatement;
private CallableStatement realCallableStatement;
Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/XATransactionState.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/XATransactionState.java?view=diff&rev=126463&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/XATransactionState.java&r1=126462&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/XATransactionState.java&r2=126463
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/XATransactionState.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/XATransactionState.java Tue Jan 25 20:23:14 2005
@@ -2,7 +2,7 @@
Derby - Class org.apache.derby.jdbc.XATransactionState
- Copyright 2003, 2004 The Apache Software Foundation or its licensors, as applicable.
+ Copyright 2003, 2005 The Apache Software Foundation or its licensors, as applicable.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@
package org.apache.derby.jdbc;
-import org.apache.derby.impl.jdbc.EmbedConnection20;
+import org.apache.derby.impl.jdbc.EmbedConnection;
import javax.transaction.xa.XAResource;
import org.apache.derby.iapi.services.context.ContextImpl;
import org.apache.derby.iapi.services.context.ContextManager;
@@ -45,7 +45,7 @@
// final static int T2_ASSOCIATION_SUSPENDED = 2;
final static int TC_COMPLETED = 3; // rollback/commit called
- public final EmbedConnection20 conn;
+ public final EmbedConnection conn;
final EmbedXAConnection creatingResource;
private EmbedXAConnection associatedResource; // owning XAResource
final XAXactId xid;
@@ -72,7 +72,7 @@
*/
boolean isPrepared;
- XATransactionState(ContextManager cm, EmbedConnection20 conn, EmbedXAConnection resource, XAXactId xid) {
+ XATransactionState(ContextManager cm, EmbedConnection conn, EmbedXAConnection resource, XAXactId xid) {
super(cm, "XATransactionState");
this.conn = conn;