db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "V.Narayanan" <V.Naraya...@Sun.COM>
Subject Re: svn commit: r398940 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ engine/org/apache/derby/iapi/jdbc/ engine/org/apache/derby/impl/jdbc/ testing/org/apache/derbyTesting/functionTests/suites/ testing/org/apache/derbyTesting/functionT...
Date Tue, 02 May 2006 14:04:29 GMT
This commit and the commit for 1180 intoduces new conflicts for the 941 
Statement Event Listeners patch. I will resolve these conflicts and will 
re-submit my patch.
thanx
Narayanan

kahatlen@apache.org wrote On 05/02/06 19:16,:

>Author: kahatlen
>Date: Tue May  2 06:46:51 2006
>New Revision: 398940
>
>URL: http://svn.apache.org/viewcvs?rev=398940&view=rev
>Log:
>DERBY-1235: Move isPoolable() and setPoolable() from PreparedStatement
>to Statement
>
>Moved setPoolable() and isPoolable() from PreparedStatement to
>Statement and implemented the methods in BrokeredStatement.
>
>Contributed by Dyre Tjeldvoll.
>
>Added:
>    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/XA40Test.java
  (with props)
>Modified:
>    db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
>    db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement40.java
>    db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java
>    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement40.java
>    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement40.java
>    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement40.java
>    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
>    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java
>    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall
>    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTest.java
>
>Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
>URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java?rev=398940&r1=398939&r2=398940&view=diff
>==============================================================================
>--- db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
(original)
>+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
Tue May  2 06:46:51 2006
>@@ -53,10 +53,6 @@
>     boolean[] parameterSet_;
>     boolean[] parameterRegistered_;
>     
>-    // By default a PreparedStatement is poolable when it is created
>-    //required for jdbc4.0 methods
>-    private boolean isPoolable = true;    
>-
>     void setInput(int parameterIndex, Object input) {
>         parameters_[parameterIndex - 1] = input;
>         parameterSet_[parameterIndex - 1] = true;
>@@ -120,6 +116,8 @@
>                              String sql,
>                              Section section) throws SqlException {
>         super(agent, connection);
>+        // PreparedStatement is poolable by default
>+        isPoolable = true;
>         initPreparedStatement(sql, section);
>     }
> 
>@@ -145,8 +143,13 @@
>     public PreparedStatement(Agent agent,
>                              Connection connection,
>                              String sql,
>-                             int type, int concurrency, int holdability, int autoGeneratedKeys,
String[] columnNames) throws SqlException {
>-        super(agent, connection, type, concurrency, holdability, autoGeneratedKeys, columnNames);
>+                             int type, int concurrency, int holdability, 
>+                             int autoGeneratedKeys, String[] columnNames) 
>+        throws SqlException {
>+        super(agent, connection, type, concurrency, holdability, 
>+              autoGeneratedKeys, columnNames);
>+        // PreparedStatement is poolable by default
>+        isPoolable = true;
>         initPreparedStatement(sql);
>     }
> 
>@@ -2110,61 +2113,4 @@
>             }
>         }
>     }    
>-    
>-    /**
>-     * Requests that a PreparedStatement be pooled or not.
>-     *
>-     * @param poolable requests that the statement be pooled if true and that the
>-     *                 statement not be pooled if false
>-     * @throws SQLException if the PreparedStatement has been closed.
>-     */
>-    
>-    public void setPoolable(boolean poolable)
>-    throws SQLException {
>-        try
>-        {
>-            synchronized (connection_) {
>-                if (agent_.loggingEnabled()) {
>-                    agent_.logWriter_.traceEntry(this, "setPoolable", poolable);
>-                }
>-                // Assert the statement has not been closed
>-                checkForClosedStatement();
>-            
>-                isPoolable = poolable;        
>-            }
>-        }
>-        catch (SqlException se)
>-        {
>-            throw se.getSQLException();
>-        }
>-    }
>-    
>-    /**
>-     * Returns the value of the statements poolable hint, indicating whether
>-     * pooling of the statement is requested.
>-     *
>-     * @return The value of the statement's poolable hint.
>-     * @throws SQLException if the PreparedStatement has been closed.
>-     */
>-
>-    public boolean isPoolable()
>-    throws SQLException{
>-        try
>-        {
>-            synchronized (connection_) {
>-                if (agent_.loggingEnabled()) {
>-                    agent_.logWriter_.traceEntry(this, "isPoolable");
>-                }
>-                // Assert the statement has not been closed
>-                checkForClosedStatement();
>-            
>-                return isPoolable;
>-            }
>-        }
>-        catch (SqlException se)
>-        {
>-            throw se.getSQLException();
>-        }
>-    }    
>-
> }
>
>Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement40.java
>URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement40.java?rev=398940&r1=398939&r2=398940&view=diff
>==============================================================================
>--- db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement40.java
(original)
>+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement40.java
Tue May  2 06:46:51 2006
>@@ -31,9 +31,6 @@
> import org.apache.derby.shared.common.reference.SQLState;
> 
> public class  PreparedStatement40 extends  org.apache.derby.client.am.PreparedStatement{
>-    
>-    // By default a PreparedStatement is poolable when it is created
>-    private boolean isPoolable = true;
> 
>     public PreparedStatement40(Agent agent,
>         Connection connection,
>
>Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java
>URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java?rev=398940&r1=398939&r2=398940&view=diff
>==============================================================================
>--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java (original)
>+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java Tue May
 2 06:46:51 2006
>@@ -191,6 +191,9 @@
> 
>     private SqlWarning warnings_ = null;
> 
>+    // A Statement is NOT poolable by default. The constructor for
>+    // PreparedStatement overrides this.
>+    protected boolean isPoolable = false;    
> 
>     //---------------------constructors/finalizer/accessors--------------------
> 
>@@ -550,6 +553,54 @@
>         }
>     }
> 
>+    /**
>+     * Returns the value of the poolable hint, indicating whether
>+     * pooling is requested.
>+     *
>+     * @return The value of the poolable hint.
>+     * @throws SQLException if the Statement has been closed.
>+     */
>+    public boolean isPoolable() throws SQLException {
>+        try {
>+            synchronized (connection_) {
>+                if (agent_.loggingEnabled()) {
>+                    agent_.logWriter_.traceEntry(this, "isPoolable");
>+                }
>+                // Assert the statement has not been closed
>+                checkForClosedStatement();
>+                
>+                return isPoolable;
>+            }
>+        }
>+        catch (SqlException se) {
>+            throw se.getSQLException();
>+        }
>+    }    
>+    
>+    /**
>+     * Requests that a Statement be pooled or not.
>+     *
>+     * @param poolable requests that the Statement be pooled if true 
>+     * and not be pooled if false.
>+     * @throws SQLException if the Statement has been closed.
>+     */
>+    public void setPoolable(boolean poolable) throws SQLException {
>+        try {
>+            synchronized (connection_) {
>+                if (agent_.loggingEnabled()) {
>+                    agent_.logWriter_.traceEntry(this, "setPoolable", poolable);
>+                }
>+                // Assert the statement has not been closed
>+                checkForClosedStatement();
>+                
>+                isPoolable = poolable;        
>+            }
>+        }
>+        catch (SqlException se) {
>+            throw se.getSQLException();
>+        }
>+    }    
>+    
>     public int getMaxFieldSize() throws SQLException {
>         try
>         {
>
>Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement40.java
>URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement40.java?rev=398940&r1=398939&r2=398940&view=diff
>==============================================================================
>--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement40.java
(original)
>+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement40.java
Tue May  2 06:46:51 2006
>@@ -175,16 +175,6 @@
>         getPreparedStatement().setSQLXML(parameterIndex,xmlObject);
>     }
>     
>-    public void setPoolable(boolean poolable)
>-    throws SQLException{
>-        getPreparedStatement().setPoolable(poolable);
>-    }
>-    
>-    public boolean isPoolable()
>-    throws SQLException{
>-        return getPreparedStatement().isPoolable();
>-    }
>-    
>     /**
>      * Returns false unless <code>interfaces</code> is implemented 
>      * 
>@@ -219,5 +209,22 @@
>                     interfaces);
>         }
>     }
>-    
>+    /** 
>+     * Forwards to the real CallableStatement.
>+     * @return true if the underlying CallableStatement is poolable,
>+     * false otherwise.
>+     * @throws SQLException if the forwarding call fails.
>+     */
>+    public boolean isPoolable() throws SQLException {
>+        return getStatement().isPoolable();
>+    }
>+
>+    /** 
>+     * Forwards to the real CallableStatement.
>+     * @param poolable new value for the poolable hint.
>+     * @throws SQLException if the forwarding call fails.
>+     */
>+    public void setPoolable(boolean poolable) throws SQLException {
>+        getStatement().setPoolable(poolable);
>+    }    
> }
>
>Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement40.java
>URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement40.java?rev=398940&r1=398939&r2=398940&view=diff
>==============================================================================
>--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement40.java
(original)
>+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement40.java
Tue May  2 06:46:51 2006
>@@ -69,16 +69,6 @@
>         throw Util.notImplemented();
>     }
>     
>-    public void setPoolable(boolean poolable)
>-    throws SQLException{
>-        throw Util.notImplemented();
>-    }
>-    
>-    public boolean isPoolable()
>-    throws SQLException{
>-        throw Util.notImplemented();
>-    }
>-    
>     /**
>      * Returns false unless <code>interfaces</code> is implemented 
>      * 
>@@ -113,5 +103,23 @@
>                     interfaces);
>         }
>     }
>-    
>+
>+    /** 
>+     * Forwards to the real PreparedStatement.
>+     * @return true if the underlying PreparedStatement is poolable,
>+     * false otherwise.
>+     * @throws SQLException if the forwarding call fails.
>+     */
>+    public boolean isPoolable() throws SQLException {
>+        return getStatement().isPoolable();
>+    }
>+
>+    /** 
>+     * Forwards to the real PreparedStatement.
>+     * @param poolable the new value for the poolable hint.
>+     * @throws SQLException if the forwarding call fails.
>+     */
>+    public void setPoolable(boolean poolable) throws SQLException {
>+        getStatement().setPoolable(poolable);
>+    }    
> }
>
>Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement40.java
>URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement40.java?rev=398940&r1=398939&r2=398940&view=diff
>==============================================================================
>--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement40.java
(original)
>+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement40.java
Tue May  2 06:46:51 2006
>@@ -74,4 +74,22 @@
>                     interfaces);
>         }
>     }
>+
>+    /** 
>+     * Forwards to the real Statement.
>+     * @return true if the underlying Statement is poolable, false otherwise.
>+     * @throws SQLException if the forwarding call fails.
>+     */
>+    public boolean isPoolable() throws SQLException {
>+        return getStatement().isPoolable();
>+    }
>+
>+    /** 
>+     * Forwards to the real Statement.
>+     * @param poolable the new value for the poolable hint.
>+     * @throws SQLException if the forwarding call fails.
>+     */
>+    public void setPoolable(boolean poolable) throws SQLException {
>+        getStatement().setPoolable(poolable);
>+    }
> }
>
>Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
>URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java?rev=398940&r1=398939&r2=398940&view=diff
>==============================================================================
>--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
(original)
>+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
Tue May  2 06:46:51 2006
>@@ -98,10 +98,6 @@
>         
>         private BrokeredConnectionControl bcc=null;
> 
>-    // By default a PreparedStatement is poolable when it is created
>-    //required for jdbc4.0 methods        
>-    private boolean isPoolable = true;
>-
> 	/*
> 		Constructor assumes caller will setup context stack
> 		and restore it.
>@@ -115,6 +111,8 @@
> 		throws SQLException {
> 
> 		super(conn, forMetaData, resultSetType, resultSetConcurrency, resultSetHoldability);
>+		// PreparedStatement is poolable by default
>+		isPoolable = true;
> 
> 		// if the sql string is null, raise an error
> 		if (sql == null)
>@@ -1570,35 +1568,4 @@
>             setBinaryStreamInternal(parameterIndex,inputStream,length);
>         }
>     }        
>-    /**
>-     * Requests that a PreparedStatement be pooled or not.
>-     *
>-     * @param poolable requests that the statement be pooled if true and that the
>-     *                 statement not be pooled if false
>-     * @throws SQLException if the PreparedStatement has been closed.
>-     */
>-     
>-    public void setPoolable(boolean poolable)
>-    throws SQLException {
>-        // Assert the statement is still active (not closed)
>-        checkStatus();
>-
>-        isPoolable = poolable;
>-    }
>-    
>-    /**
>-     * Returns the value of the statements poolable hint, indicating whether
>-     * pooling of the statement is requested.
>-     *
>-     * @return The value of the statement's poolable hint.
>-     * @throws SQLException if the PreparedStatement has been closed.
>-     */
>-
>-    public boolean isPoolable()
>-    throws SQLException {
>-        // Assert the statement is still active (not closed)
>-        checkStatus();
>-
>-        return isPoolable;
>-    }                
> }
>
>Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java
>URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java?rev=398940&r1=398939&r2=398940&view=diff
>==============================================================================
>--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java (original)
>+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java Tue
May  2 06:46:51 2006
>@@ -109,6 +109,10 @@
> 
> 	private ParameterValueSet pvs;
> 
>+	// An EmbedStatement is NOT poolable by default. The constructor for
>+	// PreparedStatement overrides this.
>+	protected boolean isPoolable = false;
>+
> 	//
> 	// constructor
> 	//
>@@ -1566,5 +1570,35 @@
>         return applicationStatement.getResultSetHoldability() ==
>             JDBC30Translation.HOLD_CURSORS_OVER_COMMIT;
>     }
>+
>+	/**
>+	 * Returns the value of the EmbedStatement's poolable hint,
>+	 * indicating whether pooling is requested.
>+	 *
>+	 * @return The value of the poolable hint.
>+	 * @throws SQLException if the Statement has been closed.
>+	 */
>+
>+	public boolean isPoolable() throws SQLException {
>+		// Assert the statement is still active (not closed)
>+		checkStatus();
>+
>+		return isPoolable;
>+	}                
>+
>+	/**
>+	 * Requests that an EmbedStatement be pooled or not.
>+	 *
>+	 * @param poolable requests that the EmbedStatement be pooled if true
>+	 * and not be pooled if false.
>+	 * @throws SQLException if the EmbedStatement has been closed.
>+	 */
>+     
>+	public void setPoolable(boolean poolable) throws SQLException {
>+		// Assert the statement is still active (not closed)
>+		checkStatus();
>+
>+		isPoolable = poolable;
>+	}
> }
> 
>
>Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall
>URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall?rev=398940&r1=398939&r2=398940&view=diff
>==============================================================================
>--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall
(original)
>+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall
Tue May  2 06:46:51 2006
>@@ -15,3 +15,4 @@
> jdbc4/ResultSetMetaDataTest.junit
> jdbc4/ParameterMetaDataWrapperTest.junit
> jdbc4/AutoloadTest.junit
>+jdbc4/XA40Test.junit
>
>Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTest.java
>URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTest.java?rev=398940&r1=398939&r2=398940&view=diff
>==============================================================================
>--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTest.java
(original)
>+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTest.java
Tue May  2 06:46:51 2006
>@@ -279,7 +279,20 @@
>             }
>         }
>     }
>-    
>+
>+    /**
>+     * Tests isPoolable, setPoolable, and the default poolability.
>+     */
>+    public void testPoolable() throws SQLException {
>+        assertFalse("Statement cannot be poolable by default", 
>+                    stmt.isPoolable()); 
>+        stmt.setPoolable(true);
>+        assertTrue("Statement must be poolable", stmt.isPoolable());
>+
>+        stmt.setPoolable(false);
>+        assertFalse("Statement cannot be poolable", stmt.isPoolable());
>+    }
>+
>     /**
>      * Create test suite for StatementTest.
>      */
>
>Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/XA40Test.java
>URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/XA40Test.java?rev=398940&view=auto
>==============================================================================
>--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/XA40Test.java
(added)
>+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/XA40Test.java
Tue May  2 06:46:51 2006
>@@ -0,0 +1,186 @@
>+/*
>+ *
>+ * Derby - Class XA40Test
>+ *
>+ * Copyright 2006 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.
>+ * You may obtain a copy of the License at
>+ *
>+ *    http://www.apache.org/licenses/LICENSE-2.0
>+ *
>+ * Unless required by applicable law or agreed to in writing, 
>+ * software distributed under the License is distributed on an 
>+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
>+ * either express or implied. See the License for the specific 
>+ * language governing permissions and limitations under the License.
>+ */
>+
>+package org.apache.derbyTesting.functionTests.tests.jdbc4;
>+
>+import org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase;
>+
>+import junit.framework.*;
>+
>+import java.sql.*;
>+
>+import javax.sql.XAConnection;
>+import javax.sql.XADataSource;
>+import javax.transaction.xa.XAResource;
>+
>+import org.apache.derby.iapi.jdbc.BrokeredStatement40;
>+import org.apache.derby.iapi.jdbc.BrokeredPreparedStatement40;
>+import org.apache.derby.iapi.jdbc.BrokeredCallableStatement40;
>+
>+
>+/**
>+ * Test new methods added for XA in JDBC4.
>+ */
>+public class XA40Test extends BaseJDBCTestCase {
>+
>+    /** Default XADataSource used by the tests. */
>+    private XADataSource xads = null;
>+
>+    /** Default XAConnection used by the tests. */
>+    private XAConnection xac = null;
>+
>+    /** Default XAResource used by the tests. */
>+    private XAResource xar = null;
>+
>+    /** Default Connection used by the tests. */
>+    private Connection con = null;
>+    
>+    /**
>+     * Create a new test with the given name.
>+     *
>+     * @param name name of the test.
>+     */
>+    public XA40Test(String name) {
>+        super(name);
>+    }
>+
>+    /**
>+     * Create default XADataSource, XAResource, XAConnection, and
>+     * Connection for the tests.
>+     *
>+     * @throws SQLException if a database access exception occurs.
>+     */
>+    public void setUp() 
>+        throws SQLException {
>+        xads = getXADataSource();
>+        xac = xads.getXAConnection();
>+        xar = xac.getXAResource();
>+        con = xac.getConnection();
>+        assertFalse("Connection must be open initially", con.isClosed());
>+        con.setAutoCommit(false);
>+    }
>+
>+    /**
>+     * Close default connection and XAConnection if necessary.
>+     *
>+     * @throws SQLException if a database access exception occurs.
>+     */
>+    public void tearDown() 
>+        throws SQLException {
>+        // Close default connection
>+        // Check if connection is open to avoid exception on rollback.
>+        if (con != null && !con.isClosed()) {
>+            // Abort changes that may have been done in the test.
>+            // The test-method may however commit these itself.
>+            con.rollback();
>+            con.close();
>+        }
>+        if (xac != null) {
>+            xac.close();
>+        }
>+    }
>+
>+    
>+    /**
>+     * Tests isPoolable(), setPoolable(boolean) and default
>+     * poolability for Statement, (which for XA is actually a
>+     * BrokeredStatement40 in embedded).
>+     *
>+     * @throws SQLException if a database access exception occurs.
>+     */
>+    public void testStatementPoolable() throws SQLException {
>+        Statement s = con.createStatement();
>+        if (usingEmbedded()) {
>+            assertTrue("s must be an instance of BrokeredStatement40, " + 
>+                       "but is " + s.getClass(), 
>+                       (s instanceof BrokeredStatement40));
>+        }
>+        assertFalse("Statement must not be poolable by default", 
>+                    s.isPoolable()); 
>+        s.setPoolable(true);
>+        assertTrue("Statement must be poolable", s.isPoolable());
>+
>+        s.setPoolable(false);
>+        assertFalse("Statement cannot be poolable", s.isPoolable());
>+    }
>+
>+    /**
>+     * Tests isPoolable() and setPoolable(boolean) for
>+     * PreparedStatement, (which for XA is actually a
>+     * BrokeredPreparedStatement40 in embedded).
>+     *
>+     * @throws SQLException if a database access exception occurs.
>+     */
>+    public void testPreparedStatementPoolable() throws SQLException {
>+        PreparedStatement ps = 
>+            con.prepareStatement("CREATE TABLE foo(i int)");
>+        if (usingEmbedded()) {
>+            assertTrue("ps must be an instance of " + 
>+                       "BrokeredPreparedStatement40, " + 
>+                       "but is " + ps.getClass(), 
>+                       (ps instanceof BrokeredPreparedStatement40));
>+        }
>+        assertTrue("PreparedStatement must be poolable by default", 
>+                    ps.isPoolable()); 
>+        ps.setPoolable(false);
>+        assertFalse("PreparedStatement cannot be poolable", ps.isPoolable());
>+
>+        ps.setPoolable(true);
>+        assertTrue("PreparedStatement must be poolable", ps.isPoolable());
>+    }
>+
>+    /**
>+     * Tests isPoolable() and setPoolable(boolean) and default
>+     * poolability for CallableStatement (which for XA is actually a
>+     * BrokeredCallableStatement40 in embedded).
>+     *
>+     * @throws SQLException if a database access exception occurs.
>+     */
>+    public void testCallableStatementPoolable() throws SQLException {
>+        CallableStatement cs = 
>+            con.prepareCall("CALL SYSCS_UTIL.SYSCS_BACKUP_DATABASE(?)");
>+        if (usingEmbedded()) {
>+            assertTrue("cs must be an instance of " + 
>+                       "BrokeredCallableStatement40, " + 
>+                       "but is " + cs.getClass(), 
>+                       (cs instanceof BrokeredCallableStatement40));
>+        }
>+        assertTrue("CallableStatement must be poolable by default", 
>+                    cs.isPoolable()); 
>+        cs.setPoolable(false);
>+        assertFalse("CallableStatement cannot be poolable", cs.isPoolable());
>+
>+        cs.setPoolable(true);
>+        assertTrue("CallableStatement must be poolable", cs.isPoolable());
>+    }
>+
>+
>+    /**
>+     * Create test suite for XA40Test.
>+     */
>+    public static Test suite() {
>+        TestSuite suite = new TestSuite("XA40Test suite");
>+        // Decorate test suite with a TestSetup class.
>+        suite.addTest(new TestSuite(XA40Test.class));
>+
>+        return suite;
>+    }
>+    
>+} // End class XA40Test
>
>Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/XA40Test.java
>------------------------------------------------------------------------------
>    svn:eol-style = native
>
>
>
>  
>

Mime
View raw message