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 kr...@apache.org on 2010/07/20 12:49:35 UTC
svn commit: r965793 - in /db/derby/code/trunk/java:
client/org/apache/derby/jdbc/
testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/
Author: kristwaa
Date: Tue Jul 20 10:49:35 2010
New Revision: 965793
URL: http://svn.apache.org/viewvc?rev=965793&view=rev
Log:
DERBY-4067: ClientConnectionPoolDataSource.getPooledConnection and ClientXADataSource.getXAConnection ignore connection attributes
DERBY-2468: would be nice if traceFile=filename connection attribute would be supported with ClientConnectionPoolDataSource and ClientXADataSource
Made two changes:
- moved the parsing of the connection attribute string to before the log
writer is constructed, since the construction may depend on some attributes
specified in the connection attribute string
- added parsing of the connection attribute string to the client ConnectionPool
and XA data sources
Also re-enabled 'testClientMessageTextConnectionAttribute' and removed a
work-around for the issue fixed by this commit.
Patch file: derby-4067-1a-update_attrs.diff
Modified:
db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java
db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java
db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java?rev=965793&r1=965792&r2=965793&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java Tue Jul 20 10:49:35 2010
@@ -74,6 +74,8 @@ public class ClientConnectionPoolDataSou
LogWriter dncLogWriter = null;
try
{
+ updateDataSourceValues(
+ tokenizeAttributes(getConnectionAttributes(), null));
dncLogWriter = super.computeDncLogWriterForNewConnection("_cpds");
if (dncLogWriter != null) {
dncLogWriter.traceEntry(this, "getPooledConnection");
@@ -98,6 +100,8 @@ public class ClientConnectionPoolDataSou
LogWriter dncLogWriter = null;
try
{
+ updateDataSourceValues(
+ tokenizeAttributes(getConnectionAttributes(), null));
dncLogWriter = super.computeDncLogWriterForNewConnection("_cpds");
if (dncLogWriter != null) {
dncLogWriter.traceEntry(this, "getPooledConnection", user, "<escaped>");
Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java?rev=965793&r1=965792&r2=965793&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java Tue Jul 20 10:49:35 2010
@@ -25,12 +25,9 @@ import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
-import org.apache.derby.client.am.ClientMessageId;
import org.apache.derby.client.am.LogWriter;
import org.apache.derby.client.am.SqlException;
-import org.apache.derby.client.net.NetConnection;
import org.apache.derby.client.net.NetLogWriter;
-import org.apache.derby.shared.common.error.ExceptionUtil;
/**
* ClientDataSource is a simple data source implementation
@@ -162,7 +159,18 @@ public class ClientDataSource extends Cl
* @throws java.sql.SQLException if a database-access error occurs.
*/
public Connection getConnection() throws SQLException {
- return getConnection(getUser(), getPassword());
+ LogWriter dncLogWriter = null;
+ try {
+ updateDataSourceValues(
+ tokenizeAttributes(getConnectionAttributes(), null));
+ dncLogWriter = super.computeDncLogWriterForNewConnection("_sds");
+ return getConnectionX(dncLogWriter, getUser(), getPassword());
+ } catch (SqlException se) {
+ // The method below may throw an exception.
+ handleConnectionException(dncLogWriter, se);
+ // If the exception wasn't handled so far, re-throw it.
+ throw se.getSQLException();
+ }
}
/**
@@ -184,11 +192,10 @@ public class ClientDataSource extends Cl
LogWriter dncLogWriter = null;
try
{
+ updateDataSourceValues(
+ tokenizeAttributes(getConnectionAttributes(), null));
dncLogWriter = super.computeDncLogWriterForNewConnection("_sds");
- updateDataSourceValues(tokenizeAttributes(getConnectionAttributes(), null));
- return ClientDriver.getFactory().newNetConnection
- ((NetLogWriter) dncLogWriter, user,
- password, this, -1, false);
+ return getConnectionX(dncLogWriter, user, password);
}
catch(SqlException se)
{
@@ -200,5 +207,12 @@ public class ClientDataSource extends Cl
}
+ private Connection getConnectionX(LogWriter dncLogWriter,
+ String user, String password)
+ throws SqlException {
+ return ClientDriver.getFactory().newNetConnection(
+ (NetLogWriter)dncLogWriter, user, password, this, -1, false);
+
+ }
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java?rev=965793&r1=965792&r2=965793&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientXADataSource.java Tue Jul 20 10:49:35 2010
@@ -22,11 +22,9 @@
package org.apache.derby.jdbc;
import java.sql.SQLException;
-import javax.sql.DataSource;
import javax.sql.XAConnection;
import javax.sql.XADataSource;
-import org.apache.derby.client.ClientXAConnection;
import org.apache.derby.client.net.NetLogWriter;
import org.apache.derby.client.am.LogWriter;
import org.apache.derby.client.am.SqlException;
@@ -62,13 +60,28 @@ public class ClientXADataSource extends
}
public XAConnection getXAConnection() throws SQLException {
- return getXAConnection(getUser(), getPassword());
+ NetLogWriter dncLogWriter = null;
+ try {
+ updateDataSourceValues(
+ tokenizeAttributes(getConnectionAttributes(), null));
+ dncLogWriter = (NetLogWriter)
+ super.computeDncLogWriterForNewConnection("_xads");
+ return getXAConnectionX(
+ dncLogWriter, this, getUser(), getPassword());
+ } catch (SqlException se) {
+ // The method below may throw an exception.
+ handleConnectionException(dncLogWriter, se);
+ // If the exception wasn't handled so far, re-throw it.
+ throw se.getSQLException();
+ }
}
public XAConnection getXAConnection(String user, String password) throws SQLException {
NetLogWriter dncLogWriter = null;
try
{
+ updateDataSourceValues(
+ tokenizeAttributes(getConnectionAttributes(), null));
dncLogWriter = (NetLogWriter)
super.computeDncLogWriterForNewConnection("_xads");
return getXAConnectionX(dncLogWriter, this, user, password);
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java?rev=965793&r1=965792&r2=965793&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java Tue Jul 20 10:49:35 2010
@@ -176,9 +176,8 @@ public class J2EEDataSourceTest extends
suite.addTest(new J2EEDataSourceTest("testClientDSConnectionAttributes"));
suite.addTest(new J2EEDataSourceTest(
"testClientTraceFileDSConnectionAttribute"));
- //DISABLED until DERBY-4067 is fixed.
- //suite.addTest(new J2EEDataSourceTest(
- // "testClientMessageTextConnectionAttribute"));
+ suite.addTest(new J2EEDataSourceTest(
+ "testClientMessageTextConnectionAttribute"));
suite.addTest(new J2EEDataSourceTest("testConnectionFlowCommit"));
suite.addTest(new J2EEDataSourceTest("testConnectionFlowCommitAlt"));
// Disabled because rollback flow optimization hasn't been implemented.
@@ -2889,14 +2888,8 @@ public class J2EEDataSourceTest extends
public Object run() {
for (int i=3 ; i <= 6 ; i++) {
File traceFile = new File("trace" + i + ".out");
- // Skip trace 3 and 5 until DERBY-2468/DERBY-4067 is fixed.
- if (i == 3 || i == 5)
- continue;
- else
- {
- assertTrue("Doesn't exist", traceFile.exists());
- assertTrue("Delete failed", traceFile.delete());
- }
+ assertTrue("Doesn't exist", traceFile.exists());
+ assertTrue("Delete failed", traceFile.delete());
}
return null;
}
@@ -2913,7 +2906,6 @@ public class J2EEDataSourceTest extends
* There is a corresponding fixture for clientDataSource in DataSourceTest
*
* @throws SQLException
- * NOTE: DISABLED until DERBY-4067 is fixed.
*/
public void testClientMessageTextConnectionAttribute() throws SQLException
{