[jboss-cvs] JBossAS SVN: r71461 - branches/JBPAPP_4_2_0_GA_CP/connector/src/main/org/jboss/resource/adapter/jdbc.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Mar 31 05:15:39 EDT 2008
Author: vicky.kak at jboss.com
Date: 2008-03-31 05:15:38 -0400 (Mon, 31 Mar 2008)
New Revision: 71461
Modified:
branches/JBPAPP_4_2_0_GA_CP/connector/src/main/org/jboss/resource/adapter/jdbc/WrappedStatement.java
Log:
[JBPAPP-662]Add transaction active tests to the jdbc resource adapter
Modified: branches/JBPAPP_4_2_0_GA_CP/connector/src/main/org/jboss/resource/adapter/jdbc/WrappedStatement.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/connector/src/main/org/jboss/resource/adapter/jdbc/WrappedStatement.java 2008-03-31 09:14:23 UTC (rev 71460)
+++ branches/JBPAPP_4_2_0_GA_CP/connector/src/main/org/jboss/resource/adapter/jdbc/WrappedStatement.java 2008-03-31 09:15:38 UTC (rev 71461)
@@ -62,6 +62,16 @@
lc.registerStatement(this);
}
+ protected void lock() throws SQLException
+ {
+ lc.lock();
+ }
+
+ protected void unlock()
+ {
+ lc.unlock();
+ }
+
public void close() throws SQLException
{
synchronized (lock)
@@ -77,58 +87,88 @@
public boolean execute(String sql) throws SQLException
{
- checkTransaction();
- try
- {
- checkConfiguredQueryTimeout();
- return s.execute(sql);
- }
- catch (Throwable t)
- {
- throw checkException(t);
- }
+ lock();
+ try
+ {
+ checkTransaction();
+ try
+ {
+ checkConfiguredQueryTimeout();
+ return s.execute(sql);
+ }
+ catch (Throwable t)
+ {
+ throw checkException(t);
+ }
+ }
+ finally
+ {
+ unlock();
+ }
}
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException
{
- checkTransaction();
- try
- {
- checkConfiguredQueryTimeout();
- return s.execute(sql, autoGeneratedKeys);
- }
- catch (Throwable t)
- {
- throw checkException(t);
- }
+ lock();
+ try
+ {
+ checkTransaction();
+ try
+ {
+ checkConfiguredQueryTimeout();
+ return s.execute(sql, autoGeneratedKeys);
+ }
+ catch (Throwable t)
+ {
+ throw checkException(t);
+ }
+ }
+ finally
+ {
+ unlock();
+ }
}
public boolean execute(String sql, int[] columnIndexes) throws SQLException
{
- checkTransaction();
- try
- {
- checkConfiguredQueryTimeout();
- return s.execute(sql, columnIndexes);
- }
- catch (Throwable t)
- {
- throw checkException(t);
- }
+ try
+ {
+ checkTransaction();
+ try
+ {
+ checkConfiguredQueryTimeout();
+ return s.execute(sql, columnIndexes);
+ }
+ catch (Throwable t)
+ {
+ throw checkException(t);
+ }
+ }
+ finally
+ {
+ unlock();
+ }
}
public boolean execute(String sql, String[]columnNames ) throws SQLException
{
- checkTransaction();
- try
- {
- checkConfiguredQueryTimeout();
- return s.execute(sql, columnNames);
- }
- catch (Throwable t)
- {
- throw checkException(t);
- }
+ try
+ {
+ checkTransaction();
+ try
+ {
+ checkConfiguredQueryTimeout();
+ return s.execute(sql, columnNames);
+ }
+ catch (Throwable t)
+ {
+ throw checkException(t);
+ }
+ }
+ finally
+ {
+ unlock();
+ }
}
public Connection getConnection() throws SQLException
@@ -164,73 +204,113 @@
public ResultSet executeQuery(String sql) throws SQLException
{
- checkTransaction();
- try
- {
- checkConfiguredQueryTimeout();
- ResultSet result = s.executeQuery(sql);
- return registerResultSet(result);
- }
- catch (Throwable t)
- {
- throw checkException(t);
- }
+ lock();
+ try
+ {
+ checkTransaction();
+ try
+ {
+ checkConfiguredQueryTimeout();
+ ResultSet result = s.executeQuery(sql);
+ return registerResultSet(result);
+ }
+ catch (Throwable t)
+ {
+ throw checkException(t);
+ }
+ }
+ finally
+ {
+ unlock();
+ }
}
public int executeUpdate(String sql) throws SQLException
{
- checkTransaction();
- try
- {
- checkConfiguredQueryTimeout();
- return s.executeUpdate(sql);
- }
- catch (Throwable t)
- {
- throw checkException(t);
- }
+ lock();
+ try
+ {
+ checkTransaction();
+ try
+ {
+ checkConfiguredQueryTimeout();
+ return s.executeUpdate(sql);
+ }
+ catch (Throwable t)
+ {
+ throw checkException(t);
+ }
+ }
+ finally
+ {
+ unlock();
+ }
}
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
{
- checkTransaction();
- try
- {
- checkConfiguredQueryTimeout();
- return s.executeUpdate(sql, autoGeneratedKeys);
- }
- catch (Throwable t)
- {
- throw checkException(t);
- }
+ lock();
+ try
+ {
+ checkTransaction();
+ try
+ {
+ checkConfiguredQueryTimeout();
+ return s.executeUpdate(sql, autoGeneratedKeys);
+ }
+ catch (Throwable t)
+ {
+ throw checkException(t);
+ }
+ }
+ finally
+ {
+ unlock();
+ }
}
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException
{
- checkTransaction();
- try
- {
- checkConfiguredQueryTimeout();
- return s.executeUpdate(sql, columnIndexes);
- }
- catch (Throwable t)
- {
- throw checkException(t);
- }
+ lock();
+ try
+ {
+ checkTransaction();
+ try
+ {
+ checkConfiguredQueryTimeout();
+ return s.executeUpdate(sql, columnIndexes);
+ }
+ catch (Throwable t)
+ {
+ throw checkException(t);
+ }
+ }
+ finally
+ {
+ unlock();
+ }
}
public int executeUpdate(String sql, String[] columnNames) throws SQLException
{
- checkTransaction();
- try
- {
- checkConfiguredQueryTimeout();
- return s.executeUpdate(sql, columnNames);
- }
- catch (Throwable t)
- {
- throw checkException(t);
- }
+ lock();
+ try
+ {
+ checkTransaction();
+ try
+ {
+ checkConfiguredQueryTimeout();
+ return s.executeUpdate(sql, columnNames);
+ }
+ catch (Throwable t)
+ {
+ throw checkException(t);
+ }
+ }
+ finally
+ {
+ unlock();
+ }
}
public int getMaxFieldSize() throws SQLException
@@ -486,56 +566,88 @@
public void addBatch(String sql) throws SQLException
{
- checkState();
- try
- {
- s.addBatch(sql);
- }
- catch (Throwable t)
- {
- throw checkException(t);
- }
+ lock();
+ try
+ {
+ checkTransaction();
+ try
+ {
+ s.addBatch(sql);
+ }
+ catch (Throwable t)
+ {
+ throw checkException(t);
+ }
+ }
+ finally
+ {
+ unlock();
+ }
}
public void clearBatch() throws SQLException
{
- checkState();
- try
- {
- s.clearBatch();
- }
- catch (Throwable t)
- {
- throw checkException(t);
- }
+ lock();
+ try
+ {
+ checkTransaction();
+ try
+ {
+ s.clearBatch();
+ }
+ catch (Throwable t)
+ {
+ throw checkException(t);
+ }
+ }
+ finally
+ {
+ unlock();
+ }
}
public int[] executeBatch() throws SQLException
{
- checkState();
- try
- {
- checkConfiguredQueryTimeout();
- return s.executeBatch();
- }
- catch (Throwable t)
- {
- throw checkException(t);
- }
+ lock();
+ try
+ {
+ checkTransaction();
+ try
+ {
+ checkConfiguredQueryTimeout();
+ return s.executeBatch();
+ }
+ catch (Throwable t)
+ {
+ throw checkException(t);
+ }
+ }
+ finally
+ {
+ unlock();
+ }
}
public ResultSet getGeneratedKeys() throws SQLException
{
- checkState();
- try
- {
- ResultSet resultSet = s.getGeneratedKeys();
- return registerResultSet(resultSet);
- }
- catch (Throwable t)
- {
- throw checkException(t);
- }
+ lock();
+ try
+ {
+ checkTransaction();
+ try
+ {
+ ResultSet resultSet = s.getGeneratedKeys();
+ return registerResultSet(resultSet);
+ }
+ catch (Throwable t)
+ {
+ throw checkException(t);
+ }
+ }
+ finally
+ {
+ unlock();
+ }
}
public int getResultSetHoldability() throws SQLException
@@ -553,8 +665,16 @@
public Statement getUnderlyingStatement() throws SQLException
{
- checkState();
- return s;
+ lock();
+ try
+ {
+ checkTransaction();
+ return s;
+ }
+ finally
+ {
+ unlock();
+ }
}
protected SQLException checkException(Throwable t)
@@ -575,6 +695,11 @@
lc.checkConfiguredQueryTimeout(this);
}
+ protected void checkTransactionActive() throws SQLException
+ {
+ lc.checkTransactionActive();
+ }
+
protected void internalClose() throws SQLException
{
synchronized (lock)
More information about the jboss-cvs-commits
mailing list