db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r393460 - in /db/derby/code/trunk/java/engine/org/apache/derby/jdbc: EmbedXAConnection.java EmbedXAConnection40.java XAStatementControl.java
Date Wed, 12 Apr 2006 13:47:04 GMT
Author: rhillegas
Date: Wed Apr 12 06:47:03 2006
New Revision: 393460

URL: http://svn.apache.org/viewcvs?rev=393460&view=rev
Log:
Commit Anurag's patch derby-1163_3.diff from DERBY-1163: adjustments to graph of connection
classes.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAConnection.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAConnection40.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAConnection.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAConnection.java?rev=393460&r1=393459&r2=393460&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAConnection.java Wed Apr 12
06:47:03 2006
@@ -39,7 +39,7 @@
 
 /** 
  */
-final class EmbedXAConnection extends EmbedPooledConnection
+class EmbedXAConnection extends EmbedPooledConnection
 		implements XAConnection
 
 {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAConnection40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAConnection40.java?rev=393460&r1=393459&r2=393460&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAConnection40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAConnection40.java Wed Apr
12 06:47:03 2006
@@ -20,221 +20,65 @@
 
 package org.apache.derby.jdbc;
 
-import java.sql.CallableStatement;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
 import java.sql.SQLException;
-import java.sql.Statement;
+import javax.sql.StatementEventListener;
 import javax.sql.XAConnection;
-import javax.transaction.xa.XAResource;
-import org.apache.derby.iapi.jdbc.EngineConnection;
 import org.apache.derby.iapi.jdbc.ResourceAdapter;
-import org.apache.derby.iapi.reference.JDBC30Translation;
-import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.impl.jdbc.Util;
 
 /**
  * This class implements jdbc4.0 methods of XAConnection
- * It inherits these methods from EmbedPooledConnection40
  */
-final class EmbedXAConnection40 extends EmbedPooledConnection40
+final class EmbedXAConnection40 extends EmbedXAConnection
         implements XAConnection {
-    private EmbedXAResource xaRes;
     
     /**
-     * Creates a new instance of EmbedXAConnection40. Initializes XAResource for
-     * the connection
-     * @param ds
-     * @param ra
-     * @param user
-     * @param password
-     * @param requestPassword
-     */
-    EmbedXAConnection40(EmbeddedDataSource40 ds, ResourceAdapter ra,
-            String user, String password,
-            boolean requestPassword) throws SQLException {
-        super(ds, user, password, requestPassword);
-        xaRes = new EmbedXAResource(this, ra);
-    }
-    
-    /**
-     * Retrieves an <code>XAResource</code> object that
-     * the transaction manager will use
-     * to manage this <code>XAConnection</code> object's participation in a
-     * distributed transaction.
-     *
-     * @return the <code>XAResource</code> object
-     * @exception SQLException if a database access error occurs
-     */
-    public final synchronized XAResource getXAResource() throws SQLException {
-        checkActive ();
-        return xaRes;
-    }
-    
-    /**
-     * Allow control over setting auto commit mode.
-     * @param autoCommit 
-     */
-    public void checkAutoCommit(boolean autoCommit) throws SQLException {
-        if (autoCommit && (xaRes.getCurrentXid() != null))
-            throw Util.generateCsSQLException(SQLState.CANNOT_AUTOCOMMIT_XA);
-        
-        super.checkAutoCommit(autoCommit);
+     * Creates EmbedXAConnection40.
+     * @param ds 
+     * @param ra 
+     * @param user 
+     * @param password 
+     * @param requestPassword 
+     */
+    	EmbedXAConnection40 (EmbeddedDataSource ds, ResourceAdapter ra, 
+                String user, String password, 
+                boolean requestPassword) throws SQLException {
+		super(ds, ra, user, password, requestPassword);
+	}
+    /**
+     * Removes the specified <code>StatementEventListener</code> from the list
of 
+     * components that will be notified when the driver detects that a 
+     * <code>PreparedStatement</code> has been closed or is invalid.
+     * <p> 
+     * 
+     * @param listener	the component which implements the
+     * <code>StatementEventListener</code> interface that was previously 
+     * registered with this <code>PooledConnection</code> object
+     * <p>
+     * @since 1.6
+     */
+    public void removeStatementEventListener(StatementEventListener listener) {
+        throw new UnsupportedOperationException (
+                "addStatementEventListener(StatementEventListener listener)");
     }
 
     /**
-     * Are held cursors allowed. If the connection is attached to
-     * a global transaction then downgrade the result set holdabilty
-     * to CLOSE_CURSORS_AT_COMMIT if downgrade is true, otherwise
-     * throw an exception.
-     * If the connection is in a local transaction then the
-     * passed in holdabilty is returned.
-     * @param holdability 
-     * @param downgrade 
-     * @return holdability
-     */
-    public int checkHoldCursors(int holdability, boolean downgrade)
-                                                        throws SQLException {
-        if (holdability == JDBC30Translation.HOLD_CURSORS_OVER_COMMIT) {
-            if (xaRes.getCurrentXid() != null) {
-                if (downgrade)
-                    return JDBC30Translation.CLOSE_CURSORS_AT_COMMIT;
-                throw Util.generateCsSQLException(SQLState.CANNOT_HOLD_CURSOR_XA);
-            }
-        }
-        
-        return super.checkHoldCursors(holdability, downgrade);
-    }
-        
-    /**
-     * Allow control over creating a Savepoint (JDBC 3.0)
-     */
-    public void checkSavepoint() throws SQLException {
-        
-        if (xaRes.getCurrentXid() != null)
-            throw Util.generateCsSQLException(SQLState.CANNOT_ROLLBACK_XA);
-        
-        super.checkSavepoint();
-    }
-    
-    /**
-     * Allow control over calling rollback.
-     */
-    public void checkRollback() throws SQLException {
-        
-        if (xaRes.getCurrentXid() != null)
-            throw Util.generateCsSQLException(SQLState.CANNOT_ROLLBACK_XA);
-        
-        super.checkRollback();
-    }
-    /**
-     * Allow control over calling commit.
-     */
-    public void checkCommit() throws SQLException {
-        
-        if (xaRes.getCurrentXid() != null)
-            throw Util.generateCsSQLException(SQLState.CANNOT_COMMIT_XA);
-        
-        super.checkCommit();
-    }
-    
-    /**
-     * Create an object handle for a database connection.
-     * @return a Connection object
-     * @exception SQLException - if a database-access error occurs.
-     */
-    public Connection getConnection() throws SQLException {
-        Connection handle;
-        
-        // Is this just a local transaction?
-        if (xaRes.getCurrentXid() == null) {
-            handle = super.getConnection();
-        } else {
-            
-            if (currentConnectionHandle != null) {
-                // this can only happen if someone called start(Xid),
-                // getConnection, getConnection (and we are now the 2nd
-                // getConnection call).
-                // Cannot yank a global connection away like, I don't think...
-                throw Util.generateCsSQLException(
-                        SQLState.CANNOT_CLOSE_ACTIVE_XA_CONNECTION);
-            }
-            
-            handle = getNewCurrentConnectionHandle();
-        }
-        
-        currentConnectionHandle.syncState();
-        
-        return handle;
-    }
-    
-    /**
-     * Wrap and control a Statement
-     * @param s 
-     * @return Statement
-     */
-    public Statement wrapStatement(Statement s) throws SQLException {
-        XAStatementControl sc = new XAStatementControl(this, s);
-        return sc.applicationStatement;
-    }
-    
-    /**
-     * Wrap and control a PreparedStatement
-     * @param ps 
-     * @param sql 
-     * @param generatedKeys 
-     * @return PreparedStatement
-     */
-    public PreparedStatement wrapStatement(PreparedStatement ps, String sql, 
-                                    Object generatedKeys) throws SQLException {
-        XAStatementControl sc = new XAStatementControl(this, ps, 
-                                                        sql, generatedKeys);
-        return (PreparedStatement) sc.applicationStatement;
-    }
-    
-    /**
-     * Wrap and control a PreparedStatement
-     * @param cs 
-     * @param sql 
-     * @return CallableStatement
-     */
-    public CallableStatement wrapStatement(CallableStatement cs, 
-                                        String sql) throws SQLException {
-        XAStatementControl sc = new XAStatementControl(this, cs, sql);
-        return (CallableStatement) sc.applicationStatement;
+     * Registers a <code>StatementEventListener</code> with this 
+     * <code>PooledConnection</code> object.  Components that 
+     * wish to be notified when  <code>PreparedStatement</code>s created by the
+     * connection are closed or are detected to be invalid may use this method 
+     * to register a <code>StatementEventListener</code> with this 
+     * <code>PooledConnection</code> object.
+     * <p>
+     * 
+     * @param listener	an component which implements the 
+     * <code>StatementEventListener</code> interface that is to be registered
+     * with this <code>PooledConnection</code> object
+     * <p>
+     * @since 1.6
+     */
+    public void addStatementEventListener(StatementEventListener listener) {
+        throw new UnsupportedOperationException (
+                "addStatementEventListener(StatementEventListener listener)");
     }
-    
-    /**
-     * Override getRealConnection to create a a local connection
-     * when we are not associated with an XA transaction.
-     *
-     * This can occur if the application has a Connection object (conn)
-     * and the following sequence occurs.
-     *
-     * conn = xac.getConnection();
-     * xac.start(xid, ...)
-     *
-     * // do work with conn
-     *
-     * xac.end(xid, ...);
-     *
-     * // do local work with conn
-     * // need to create new connection here.
-     */
-    public EngineConnection getRealConnection() throws SQLException {
-        EngineConnection rc = super.getRealConnection();
-        if (rc != null)
-            return rc;
-        
-        openRealConnection();
-        
-        // a new Connection, set its state according to the application's 
-        //Connection handle
-        currentConnectionHandle.setState(true);        
-        return realConnection;
-    }
-    
-    
-    
-    
-}
+   
+}
\ No newline at end of file

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java?rev=393460&r1=393459&r2=393460&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java Wed Apr
12 06:47:03 2006
@@ -42,7 +42,7 @@
 
 	/**
 	*/
-	private final EmbedPooledConnection	xaConnection;
+	private final EmbedXAConnection	xaConnection;
 	private final BrokeredConnection	applicationConnection;
 	BrokeredStatement		applicationStatement;
 	private EmbedConnection	realConnection;
@@ -50,13 +50,13 @@
 	private PreparedStatement	realPreparedStatement;
 	private CallableStatement	realCallableStatement;
 
-	private XAStatementControl(EmbedPooledConnection xaConnection) {
+	private XAStatementControl(EmbedXAConnection xaConnection) {
 		this.xaConnection = xaConnection;
 		this.realConnection = xaConnection.realConnection;
 		this.applicationConnection = xaConnection.currentConnectionHandle;
 	}
 
-	XAStatementControl(EmbedPooledConnection xaConnection, 
+	XAStatementControl(EmbedXAConnection xaConnection, 
                                 Statement realStatement) throws SQLException {
 		this(xaConnection);
 		this.realStatement = realStatement;
@@ -65,7 +65,7 @@
         ((EmbedStatement) realStatement).setApplicationStatement(
                 applicationStatement);
 	}
-	XAStatementControl(EmbedPooledConnection xaConnection, 
+	XAStatementControl(EmbedXAConnection xaConnection, 
                 PreparedStatement realPreparedStatement, 
                 String sql, Object generatedKeys) throws SQLException {            
 		this(xaConnection);
@@ -74,7 +74,7 @@
         ((EmbedStatement) realPreparedStatement).setApplicationStatement(
                 applicationStatement);
 	}
-	XAStatementControl(EmbedPooledConnection xaConnection, 
+	XAStatementControl(EmbedXAConnection xaConnection, 
                 CallableStatement realCallableStatement, 
                 String sql) throws SQLException {
 		this(xaConnection);



Mime
View raw message