Author: rhillegas
Date: Mon May 22 12:39:31 2006
New Revision: 408733
URL: http://svn.apache.org/viewvc?rev=408733&view=rev
Log:
DERBY-1214: Anurag's derby-1214_2.diff patch. This forwards new JDBC4 calls on Pooled and
XA objects to the appropriate worker objects.
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement40.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunList.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunTest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/BaseJDBCTestCase.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestConfiguration.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java?rev=408733&r1=408732&r2=408733&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java Mon
May 22 12:39:31 2006
@@ -43,8 +43,13 @@
}
public Array createArray(String typeName, Object[] elements)
- throws SQLException {
- throw Util.notImplemented();
+ throws SQLException {
+ try {
+ return getRealConnection().createArray (typeName, elements);
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
}
/**
@@ -101,16 +106,31 @@
public NClob createNClob() throws SQLException{
- throw Util.notImplemented();
+ try {
+ return getRealConnection().createNClob();
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
}
public SQLXML createSQLXML() throws SQLException{
- throw Util.notImplemented();
+ try {
+ return getRealConnection().createSQLXML ();
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
}
public Struct createStruct(String typeName, Object[] attributes)
- throws SQLException {
- throw Util.notImplemented();
+ throws SQLException {
+ try {
+ return getRealConnection().createStruct (typeName, attributes);
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
}
@@ -249,15 +269,30 @@
* @return an instance of BrokeredStatement40
* throws java.sql.SQLException
*/
- public BrokeredStatement newBrokeredStatement
+ public final BrokeredStatement newBrokeredStatement
(BrokeredStatementControl statementControl) throws SQLException {
- return new BrokeredStatement40(statementControl, getJDBCLevel());
+ try {
+ return new BrokeredStatement40(statementControl, getJDBCLevel());
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
}
- public BrokeredPreparedStatement newBrokeredStatement(BrokeredStatementControl statementControl,
String sql, Object generatedKeys) throws SQLException {
- return new BrokeredPreparedStatement40(statementControl, getJDBCLevel(), sql, generatedKeys);
+ public final BrokeredPreparedStatement newBrokeredStatement(BrokeredStatementControl
statementControl, String sql, Object generatedKeys) throws SQLException {
+ try {
+ return new BrokeredPreparedStatement40(statementControl, getJDBCLevel(), sql,
generatedKeys);
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
}
- public BrokeredCallableStatement newBrokeredStatement(BrokeredStatementControl statementControl,
String sql) throws SQLException {
- return new BrokeredCallableStatement40(statementControl, getJDBCLevel(), sql);
+ public final BrokeredCallableStatement newBrokeredStatement(BrokeredStatementControl
statementControl, String sql) throws SQLException {
+ try {
+ return new BrokeredCallableStatement40(statementControl, getJDBCLevel(), sql);
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
}
/**
@@ -266,7 +301,7 @@
* @return type map for this connection
* @exception SQLException if a database access error occurs
*/
- public java.util.Map<String,Class<?>> getTypeMap() throws SQLException {
+ public final java.util.Map<String,Class<?>> getTypeMap() throws SQLException
{
try {
return getRealConnection().getTypeMap();
} catch (SQLException se) {
@@ -275,7 +310,7 @@
}
}
- int getJDBCLevel() { return 4;}
+ final int getJDBCLevel() { return 4;}
/**
* Returns false unless <code>interfaces</code> is implemented
@@ -288,7 +323,7 @@
* whether this is a wrapper for an object
* with the given interface.
*/
- public boolean isWrapperFor(Class<?> interfaces) throws SQLException {
+ public final boolean isWrapperFor(Class<?> interfaces) throws SQLException {
checkIfClosed();
return interfaces.isInstance(this);
}
@@ -301,7 +336,7 @@
* @throws java.sql.SQLExption if no object if found that implements the
* interface
*/
- public <T> T unwrap(java.lang.Class<T> interfaces)
+ public final <T> T unwrap(java.lang.Class<T> interfaces)
throws SQLException{
checkIfClosed();
//Derby does not implement non-standard methods on
@@ -312,6 +347,5 @@
throw Util.generateCsSQLException(SQLState.UNABLE_TO_UNWRAP,
interfaces);
}
- }
-
+ }
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement40.java?rev=408733&r1=408732&r2=408733&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
Mon May 22 12:39:31 2006
@@ -36,38 +36,38 @@
}
public void setRowId(int parameterIndex, RowId x) throws SQLException{
- throw Util.notImplemented();
+ getPreparedStatement().setRowId (parameterIndex, x);
}
public void setNString(int index, String value) throws SQLException{
- throw Util.notImplemented();
+ getPreparedStatement().setNString (index, value);
}
public void setNCharacterStream(int index, Reader value, long length) throws SQLException{
- throw Util.notImplemented();
+ getPreparedStatement().setNCharacterStream (index, value, length);
}
public void setNClob(int index, NClob value) throws SQLException{
- throw Util.notImplemented();
+ getPreparedStatement().setNClob (index, value);
}
public void setClob(int parameterIndex, Reader reader, long length)
throws SQLException{
- throw Util.notImplemented();
+ getPreparedStatement().setClob (parameterIndex, reader, length);
}
public void setBlob(int parameterIndex, InputStream inputStream, long length)
throws SQLException{
- throw Util.notImplemented();
+ getPreparedStatement().setBlob (parameterIndex, inputStream, length);
}
public void setNClob(int parameterIndex, Reader reader, long length)
throws SQLException{
- throw Util.notImplemented();
+ getPreparedStatement().setNClob (parameterIndex, reader, length);
}
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException{
- throw Util.notImplemented();
- }
+ getPreparedStatement().setSQLXML (parameterIndex, xmlObject);
+ }
/**
* Checks if the statement is closed.
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunList.java?rev=408733&r1=408732&r2=408733&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunList.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunList.java
Mon May 22 12:39:31 2006
@@ -119,6 +119,8 @@
static BufferedReader runlistFile;
static String hostName;
static String testEncoding; // Encoding used for child jvm and to read the test output
+ static String junitxasingle;// Run junit test cases with under
+ // single branck xa transaction
static String [] clientExclusionKeywords = new String [] {
"at-or-before:", "at-or-after:", "when-at-or-before:jdk",
@@ -440,6 +442,9 @@
}
else if (otherSpecialProps.length()>0)
jvmProps.addElement("testSpecialProps=" + otherSpecialProps);
+
+ if (junitxasingle != null)
+ jvmProps.addElement ("junit.xa.single=" + junitxasingle);
// Ensure any properties that define the default connection
// for the tests to use a DataSource are passed from the
@@ -757,6 +762,7 @@
jdk12exttest = suiteProperties.getProperty("jdk12exttest");
runwithibmjvm = suiteProperties.getProperty("runwithibmjvm");
runwithj9 = suiteProperties.getProperty("runwithj9");
+ junitxasingle = suiteProperties.getProperty("junit.xa.single");
String testJVM = jvmName;
if (jvmName.startsWith("j9"))
testJVM = (jvmName.equals("j9_foundation") ? "foundation" : "j9");
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunTest.java?rev=408733&r1=408732&r2=408733&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/RunTest.java
Mon May 22 12:39:31 2006
@@ -179,6 +179,7 @@
static boolean lastTestFailed = false;
static boolean isI18N = false;
+ static boolean junitXASingle = false;
/**
* Run the test without a security manager. Hopefully
@@ -903,7 +904,10 @@
framework = "";
else
driverName = NetServer.getDriverName(framework);
-
+ String junitXAProp = sp.getProperty ("junit.xa.single");
+ if (junitXAProp != null && junitXAProp.equals ("true")) {
+ junitXASingle = true;
+ }
hostName = sp.getProperty("hostName");
// force hostName to localhost if it is not set
if (hostName == null)
@@ -2200,6 +2204,9 @@
if ((hostName != null) && (!hostName.equals("localhost")))
jvmProps.addElement("hostName=" + hostName);
}
+
+ if (junitXASingle)
+ jvmProps.addElement ("junit.xa.single=true");
// if we're not jdk15, don't, we'll skip
if ((testEncoding != null) && (jvmName.equals("jdk15")))
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/BaseJDBCTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/BaseJDBCTestCase.java?rev=408733&r1=408732&r2=408733&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/BaseJDBCTestCase.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/BaseJDBCTestCase.java
Mon May 22 12:39:31 2006
@@ -70,12 +70,18 @@
throws SQLException {
Connection con = null;
JDBCClient client = CONFIG.getJDBCClient();
- if (HAVE_DRIVER) {
+ if (HAVE_DRIVER) {
loadJDBCDriver(client.getJDBCDriverName());
- con = DriverManager.getConnection(
- CONFIG.getJDBCUrl() + ";create=true",
- CONFIG.getUserName(),
- CONFIG.getUserPassword());
+ if (!CONFIG.isSingleLegXA()) {
+ con = DriverManager.getConnection(
+ CONFIG.getJDBCUrl() + ";create=true",
+ CONFIG.getUserName(),
+ CONFIG.getUserPassword());
+ }
+ else {
+ con = getXADataSource().getXAConnection (CONFIG.getUserName(),
+ CONFIG.getUserPassword()).getConnection();
+ }
} else {
//Use DataSource for JSR169
con = getDataSource().getConnection();
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestConfiguration.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestConfiguration.java?rev=408733&r1=408732&r2=408733&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestConfiguration.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestConfiguration.java
Mon May 22 12:39:31 2006
@@ -50,6 +50,8 @@
hostName = props.getProperty(KEY_HOSTNAME, DEFAULT_HOSTNAME);
isVerbose = Boolean.valueOf(props.getProperty(KEY_VERBOSE)).booleanValue();
String portStr = props.getProperty(KEY_PORT);
+ singleLegXA = Boolean.valueOf(props.getProperty(KEY_SINGLE_LEG_XA)
+ ).booleanValue();
if (portStr != null) {
try {
port = Integer.parseInt(portStr);
@@ -229,6 +231,14 @@
}
/**
+ * Return if it has to run under single legged xa transaction
+ * @return singleLegXA
+ */
+ public boolean isSingleLegXA () {
+ return singleLegXA;
+ }
+
+ /**
* Immutable data members in test configuration
*/
private final Properties systemStartupProperties;
@@ -240,6 +250,7 @@
private final String hostName;
private final JDBCClient jdbcClient;
private boolean isVerbose;
+ private final boolean singleLegXA;
/**
* Default values for configurations
@@ -260,7 +271,8 @@
private final static String KEY_USER_NAME = "user";
private final static String KEY_HOSTNAME = "hostName";
private final static String KEY_PORT = "port";
- private final static String KEY_VERBOSE = "derby.tests.debug";
+ private final static String KEY_VERBOSE = "derby.tests.debug";
+ private final static String KEY_SINGLE_LEG_XA = "junit.xa.single";
/**
* Possible values of system properties.
|