From 2f10cd452065b0c1f6b23553eae61317fa3942f8 Mon Sep 17 00:00:00 2001 From: Milosz Tylenda Date: Fri, 25 Jun 2010 21:34:46 +0000 Subject: [PATCH] OPENJPA-6: Implement JDBC 3 methods in delegates. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@958120 13f79535-47bb-0310-9956-ffa450edef68 --- .../openjpa/jdbc/kernel/JDBCStoreManager.java | 145 ++++++++- .../lib/jdbc/DelegatingCallableStatement.java | 132 ++++---- .../lib/jdbc/DelegatingPreparedStatement.java | 23 +- .../openjpa/lib/jdbc/DelegatingStatement.java | 21 +- .../jdbc/JDBCEventConnectionDecorator.java | 192 +++++++++++ .../lib/jdbc/LoggingConnectionDecorator.java | 299 ++++++++++++++++++ 6 files changed, 721 insertions(+), 91 deletions(-) diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java index 6dff91342..e3cb76839 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java @@ -73,7 +73,6 @@ import org.apache.openjpa.lib.jdbc.DelegatingConnection; import org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement; import org.apache.openjpa.lib.jdbc.DelegatingStatement; import org.apache.openjpa.lib.log.Log; -import org.apache.openjpa.lib.log.LogFactoryImpl.LogImpl; import org.apache.openjpa.lib.rop.MergedResultObjectProvider; import org.apache.openjpa.lib.rop.ResultObjectProvider; import org.apache.openjpa.lib.util.ConcreteClassGenerator; @@ -1702,6 +1701,69 @@ public class JDBCStoreManager afterExecuteStatement(this); } } + + public boolean execute(String sql) throws SQLException { + beforeExecuteStatement(this); + try { + return super.execute(sql); + } finally { + afterExecuteStatement(this); + } + } + + public int executeUpdate(String sql, int i) throws SQLException { + beforeExecuteStatement(this); + try { + return super.executeUpdate(sql, i); + } finally { + afterExecuteStatement(this); + } + } + + public int executeUpdate(String sql, int[] ia) throws SQLException { + beforeExecuteStatement(this); + try { + return super.executeUpdate(sql, ia); + } finally { + afterExecuteStatement(this); + } + } + + public int executeUpdate(String sql, String[] sa) throws SQLException { + beforeExecuteStatement(this); + try { + return super.executeUpdate(sql, sa); + } finally { + afterExecuteStatement(this); + } + } + + public boolean execute(String sql, int i) throws SQLException { + beforeExecuteStatement(this); + try { + return super.execute(sql, i); + } finally { + afterExecuteStatement(this); + } + } + + public boolean execute(String sql, int[] ia) throws SQLException { + beforeExecuteStatement(this); + try { + return super.execute(sql, ia); + } finally { + afterExecuteStatement(this); + } + } + + public boolean execute(String sql, String[] sa) throws SQLException { + beforeExecuteStatement(this); + try { + return super.execute(sql, sa); + } finally { + afterExecuteStatement(this); + } + } } /** @@ -1742,6 +1804,87 @@ public class JDBCStoreManager afterExecuteStatement(this); } } + + public boolean execute() throws SQLException { + beforeExecuteStatement(this); + try { + return super.execute(); + } finally { + afterExecuteStatement(this); + } + } + + public boolean execute(String s) throws SQLException { + beforeExecuteStatement(this); + try { + return super.execute(s); + } finally { + afterExecuteStatement(this); + } + } + + public int executeUpdate(String s) throws SQLException { + beforeExecuteStatement(this); + try { + return super.executeUpdate(s); + } finally { + afterExecuteStatement(this); + } + } + + public int executeUpdate(String s, int i) throws SQLException { + beforeExecuteStatement(this); + try { + return super.executeUpdate(s, i); + } finally { + afterExecuteStatement(this); + } + } + + public int executeUpdate(String s, int[] ia) throws SQLException { + beforeExecuteStatement(this); + try { + return super.executeUpdate(s, ia); + } finally { + afterExecuteStatement(this); + } + } + + public int executeUpdate(String s, String[] sa) throws SQLException { + beforeExecuteStatement(this); + try { + return super.executeUpdate(s, sa); + } finally { + afterExecuteStatement(this); + } + } + + public boolean execute(String s, int i) throws SQLException { + beforeExecuteStatement(this); + try { + return super.execute(s, i); + } finally { + afterExecuteStatement(this); + } + } + + public boolean execute(String s, int[] ia) throws SQLException { + beforeExecuteStatement(this); + try { + return super.execute(s, ia); + } finally { + afterExecuteStatement(this); + } + } + + public boolean execute(String s, String[] sa) throws SQLException { + beforeExecuteStatement(this); + try { + return super.execute(s, sa); + } finally { + afterExecuteStatement(this); + } + } } } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java index ad95cbc00..db667d290 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java @@ -436,51 +436,50 @@ public abstract class DelegatingCallableStatement _stmnt.setNull(i1, i2, s); } - // JDBC 3.0 (unsupported) methods follow; these are required to be able - // to compile against JDK 1.4 + // JDBC 3 methods follow. public boolean getMoreResults(int i) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getMoreResults(i); } public ResultSet getGeneratedKeys() throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getGeneratedKeys(); } public int executeUpdate(String s, int i) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.executeUpdate(s, i); } public int executeUpdate(String s, int[] ia) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.executeUpdate(s, ia); } public int executeUpdate(String s, String[] sa) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.executeUpdate(s, sa); } public boolean execute(String s, int i) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.execute(s, i); } public boolean execute(String s, int[] ia) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.execute(s, ia); } public boolean execute(String s, String[] sa) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.execute(s, sa); } public int getResultSetHoldability() throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getResultSetHoldability(); } public void setURL(int i, URL url) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setURL(i, url); } public ParameterMetaData getParameterMetaData() throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getParameterMetaData(); } ///////////////////////////// @@ -601,223 +600,222 @@ public abstract class DelegatingCallableStatement _stmnt.registerOutParameter(i1, i2, s); } - // JDBC 3.0 (unsupported) methods follow; these are required to be able - // to compile against JDK 1.4 + // JDBC 3 methods follow. public void registerOutParameter(String s, int i) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.registerOutParameter(s, i); } public void registerOutParameter(String s, int i1, int i2) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.registerOutParameter(s, i1, i2); } public void registerOutParameter(String s1, int i, String s2) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.registerOutParameter(s1, i, s2); } public URL getURL(int i) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getURL(i); } public void setURL(String a, URL b) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setURL(a, b); } public URL getURL(String a) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getURL(a); } public void setNull(String a, int b) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setNull(a, b); } public void setBoolean(String a, boolean b) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setBoolean(a, b); } public void setByte(String a, byte b) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setByte(a, b); } public void setShort(String a, short b) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setShort(a, b); } public void setInt(String a, int b) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setInt(a, b); } public void setLong(String a, long b) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setLong(a, b); } public void setFloat(String a, float b) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setFloat(a, b); } public void setDouble(String a, double b) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setDouble(a, b); } public void setBigDecimal(String a, BigDecimal b) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setBigDecimal(a, b); } public void setString(String a, String b) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setString(a, b); } public void setBytes(String a, byte[] b) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setBytes(a, b); } public void setDate(String a, Date b) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setDate(a, b); } public void setTime(String a, Time b) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setTime(a, b); } public void setTimestamp(String a, Timestamp b) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setTimestamp(a, b); } public void setAsciiStream(String a, InputStream b, int c) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setAsciiStream(a, b, c); } public void setBinaryStream(String a, InputStream b, int c) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setBinaryStream(a, b, c); } public void setObject(String a, Object b, int c, int d) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setObject(a, b, c, d); } public void setObject(String a, Object b, int c) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setObject(a, b, c); } public void setObject(String a, Object b) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setObject(a, b); } public void setCharacterStream(String a, Reader b, int c) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setCharacterStream(a, b, c); } public void setDate(String a, Date b, Calendar c) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setDate(a, b, c); } public void setTime(String a, Time b, Calendar c) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setTime(a, b, c); } public void setTimestamp(String a, Timestamp b, Calendar c) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setTimestamp(a, b, c); } public void setNull(String a, int b, String c) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setNull(a, b, c); } public String getString(String a) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getString(a); } public boolean getBoolean(String a) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getBoolean(a); } public byte getByte(String a) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getByte(a); } public short getShort(String a) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getShort(a); } public int getInt(String a) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getInt(a); } public long getLong(String a) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getLong(a); } public float getFloat(String a) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getFloat(a); } public double getDouble(String a) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getDouble(a); } public byte[] getBytes(String a) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getBytes(a); } public Date getDate(String a) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getDate(a); } public Time getTime(String a) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getTime(a); } public Timestamp getTimestamp(String a) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getTimestamp(a); } public Object getObject(String a) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getObject(a); } public BigDecimal getBigDecimal(String a) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getBigDecimal(a); } public Object getObject(String a, Map>b) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getObject(a, b); } public Ref getRef(String a) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getRef(a); } public Blob getBlob(String a) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getBlob(a); } public Clob getClob(String a) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getClob(a); } public Array getArray(String a) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getArray(a); } public Date getDate(String a, Calendar b) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getDate(a, b); } public Time getTime(String a, Calendar b) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getTime(a, b); } public Timestamp getTimestamp(String a, Calendar b) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getTimestamp(a, b); } // java.sql.Wrapper implementation (JDBC 4) diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingPreparedStatement.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingPreparedStatement.java index 515cf5712..c08a16a5a 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingPreparedStatement.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingPreparedStatement.java @@ -426,11 +426,10 @@ public abstract class DelegatingPreparedStatement _stmnt.setNull(i1, i2, s); } - // JDBC 3.0 (unsupported) method follow; these are required to be able - // to compile against JDK 1.4 + // JDBC 3 methods follow. public boolean getMoreResults(int i) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getMoreResults(i); } public ResultSet getGeneratedKeys() throws SQLException { @@ -438,39 +437,39 @@ public abstract class DelegatingPreparedStatement } public int executeUpdate(String s, int i) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.executeUpdate(s, i); } public int executeUpdate(String s, int[] ia) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.executeUpdate(s, ia); } public int executeUpdate(String s, String[] sa) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.executeUpdate(s, sa); } public boolean execute(String s, int i) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.execute(s, i); } public boolean execute(String s, int[] ia) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.execute(s, ia); } public boolean execute(String s, String[] sa) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.execute(s, sa); } public int getResultSetHoldability() throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getResultSetHoldability(); } public void setURL(int i, URL url) throws SQLException { - throw new UnsupportedOperationException(); + _stmnt.setURL(i, url); } public ParameterMetaData getParameterMetaData() throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getParameterMetaData(); } // java.sql.Wrapper implementation (JDBC 4) diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingStatement.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingStatement.java index d0f1e3e12..e4771c8c4 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingStatement.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingStatement.java @@ -253,43 +253,42 @@ public abstract class DelegatingStatement implements Statement, Closeable { return _conn; } - // JDBC 3.0 (unsupported) method follow; these are required to be able - // to compile against JDK 1.4 + // JDBC 3 methods follow. public boolean getMoreResults(int i) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getMoreResults(i); } public ResultSet getGeneratedKeys() throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getGeneratedKeys(); } public int executeUpdate(String s, int i) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.executeUpdate(s, i); } public int executeUpdate(String s, int[] ia) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.executeUpdate(s, ia); } public int executeUpdate(String s, String[] sa) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.executeUpdate(s, sa); } public boolean execute(String s, int i) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.execute(s, i); } public boolean execute(String s, int[] ia) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.execute(s, ia); } public boolean execute(String s, String[] sa) throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.execute(s, sa); } public int getResultSetHoldability() throws SQLException { - throw new UnsupportedOperationException(); + return _stmnt.getResultSetHoldability(); } // java.sql.Wrapper implementation (JDBC 4) diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java index d44324fda..1bf541e56 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java @@ -288,6 +288,114 @@ public class JDBCEventConnectionDecorator extends AbstractConcurrentEventManager getDelegate(), _sql); } } + + public boolean execute() throws SQLException { + JDBCEvent before = fireEvent(_conn.getDelegate(), + JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), _sql); + try { + return super.execute(); + } finally { + fireEvent(_conn.getDelegate(), + JDBCEvent.AFTER_EXECUTE_STATEMENT, before, + getDelegate(), _sql); + } + } + + public int executeUpdate(String sql) throws SQLException { + JDBCEvent before = fireEvent(_conn.getDelegate(), + JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql); + try { + return super.executeUpdate(sql); + } finally { + fireEvent(_conn.getDelegate(), + JDBCEvent.AFTER_EXECUTE_STATEMENT, before, + getDelegate(), sql); + } + } + + public int executeUpdate(String sql, int i) throws SQLException { + JDBCEvent before = fireEvent(_conn.getDelegate(), + JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql); + try { + return super.executeUpdate(sql, i); + } finally { + fireEvent(_conn.getDelegate(), + JDBCEvent.AFTER_EXECUTE_STATEMENT, before, + getDelegate(), sql); + } + } + + public int executeUpdate(String sql, int[] ia) throws SQLException { + JDBCEvent before = fireEvent(_conn.getDelegate(), + JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql); + try { + return super.executeUpdate(sql, ia); + } finally { + fireEvent(_conn.getDelegate(), + JDBCEvent.AFTER_EXECUTE_STATEMENT, before, + getDelegate(), sql); + } + } + + public int executeUpdate(String sql, String[] sa) throws SQLException { + JDBCEvent before = fireEvent(_conn.getDelegate(), + JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql); + try { + return super.executeUpdate(sql, sa); + } finally { + fireEvent(_conn.getDelegate(), + JDBCEvent.AFTER_EXECUTE_STATEMENT, before, + getDelegate(), sql); + } + } + + public boolean execute(String sql) throws SQLException { + JDBCEvent before = fireEvent(_conn.getDelegate(), + JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql); + try { + return super.execute(sql); + } finally { + fireEvent(_conn.getDelegate(), + JDBCEvent.AFTER_EXECUTE_STATEMENT, before, + getDelegate(), sql); + } + } + + public boolean execute(String sql, int i) throws SQLException { + JDBCEvent before = fireEvent(_conn.getDelegate(), + JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql); + try { + return super.execute(sql, i); + } finally { + fireEvent(_conn.getDelegate(), + JDBCEvent.AFTER_EXECUTE_STATEMENT, before, + getDelegate(), sql); + } + } + + public boolean execute(String sql, int[] ia) throws SQLException { + JDBCEvent before = fireEvent(_conn.getDelegate(), + JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql); + try { + return super.execute(sql, ia); + } finally { + fireEvent(_conn.getDelegate(), + JDBCEvent.AFTER_EXECUTE_STATEMENT, before, + getDelegate(), sql); + } + } + + public boolean execute(String sql, String[] sa) throws SQLException { + JDBCEvent before = fireEvent(_conn.getDelegate(), + JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql); + try { + return super.execute(sql, sa); + } finally { + fireEvent(_conn.getDelegate(), + JDBCEvent.AFTER_EXECUTE_STATEMENT, before, + getDelegate(), sql); + } + } } /** @@ -326,5 +434,89 @@ public class JDBCEventConnectionDecorator extends AbstractConcurrentEventManager getDelegate(), sql); } } + + public boolean execute(String sql) throws SQLException { + JDBCEvent before = fireEvent(_conn.getDelegate(), + JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql); + try { + return super.execute(sql); + } finally { + fireEvent(_conn.getDelegate(), + JDBCEvent.AFTER_EXECUTE_STATEMENT, before, + getDelegate(), sql); + } + } + + public int executeUpdate(String sql, int i) throws SQLException { + JDBCEvent before = fireEvent(_conn.getDelegate(), + JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql); + try { + return super.executeUpdate(sql, i); + } finally { + fireEvent(_conn.getDelegate(), + JDBCEvent.AFTER_EXECUTE_STATEMENT, before, + getDelegate(), sql); + } + } + + public int executeUpdate(String sql, int[] ia) throws SQLException { + JDBCEvent before = fireEvent(_conn.getDelegate(), + JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql); + try { + return super.executeUpdate(sql, ia); + } finally { + fireEvent(_conn.getDelegate(), + JDBCEvent.AFTER_EXECUTE_STATEMENT, before, + getDelegate(), sql); + } + } + + public int executeUpdate(String sql, String[] sa) throws SQLException { + JDBCEvent before = fireEvent(_conn.getDelegate(), + JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql); + try { + return super.executeUpdate(sql, sa); + } finally { + fireEvent(_conn.getDelegate(), + JDBCEvent.AFTER_EXECUTE_STATEMENT, before, + getDelegate(), sql); + } + } + + public boolean execute(String sql, int i) throws SQLException { + JDBCEvent before = fireEvent(_conn.getDelegate(), + JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql); + try { + return super.execute(sql, i); + } finally { + fireEvent(_conn.getDelegate(), + JDBCEvent.AFTER_EXECUTE_STATEMENT, before, + getDelegate(), sql); + } + } + + public boolean execute(String sql, int[] ia) throws SQLException { + JDBCEvent before = fireEvent(_conn.getDelegate(), + JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql); + try { + return super.execute(sql, ia); + } finally { + fireEvent(_conn.getDelegate(), + JDBCEvent.AFTER_EXECUTE_STATEMENT, before, + getDelegate(), sql); + } + } + + public boolean execute(String sql, String[] sa) throws SQLException { + JDBCEvent before = fireEvent(_conn.getDelegate(), + JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql); + try { + return super.execute(sql, sa); + } finally { + fireEvent(_conn.getDelegate(), + JDBCEvent.AFTER_EXECUTE_STATEMENT, before, + getDelegate(), sql); + } + } } } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java index 735068850..53b4915af 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java @@ -22,6 +22,7 @@ import java.io.InputStream; import java.io.Reader; import java.lang.reflect.Constructor; import java.math.BigDecimal; +import java.net.URL; import java.sql.Array; import java.sql.BatchUpdateException; import java.sql.Blob; @@ -987,6 +988,102 @@ public class LoggingConnectionDecorator implements ConnectionDecorator { handleSQLErrors(LoggingStatement.this, err); } } + + public int executeUpdate(String sql, int i) throws SQLException { + _sql = sql; + logSQL(this); + long start = System.currentTimeMillis(); + SQLException err = null; + try { + return super.executeUpdate(sql, i); + } catch (SQLException se) { + err = wrap(se, LoggingStatement.this, sql); + throw err; + } finally { + logTime(start); + handleSQLErrors(LoggingStatement.this, err); + } + } + + public int executeUpdate(String sql, int[] ia) throws SQLException { + _sql = sql; + logSQL(this); + long start = System.currentTimeMillis(); + SQLException err = null; + try { + return super.executeUpdate(sql, ia); + } catch (SQLException se) { + err = wrap(se, LoggingStatement.this, sql); + throw err; + } finally { + logTime(start); + handleSQLErrors(LoggingStatement.this, err); + } + } + + public int executeUpdate(String sql, String[] sa) throws SQLException { + _sql = sql; + logSQL(this); + long start = System.currentTimeMillis(); + SQLException err = null; + try { + return super.executeUpdate(sql, sa); + } catch (SQLException se) { + err = wrap(se, LoggingStatement.this, sql); + throw err; + } finally { + logTime(start); + handleSQLErrors(LoggingStatement.this, err); + } + } + + public boolean execute(String sql, int i) throws SQLException { + _sql = sql; + logSQL(this); + long start = System.currentTimeMillis(); + SQLException err = null; + try { + return super.execute(sql, i); + } catch (SQLException se) { + err = wrap(se, LoggingStatement.this, sql); + throw err; + } finally { + logTime(start); + handleSQLErrors(LoggingStatement.this, err); + } + } + + public boolean execute(String sql, int[] ia) throws SQLException { + _sql = sql; + logSQL(this); + long start = System.currentTimeMillis(); + SQLException err = null; + try { + return super.execute(sql, ia); + } catch (SQLException se) { + err = wrap(se, LoggingStatement.this, sql); + throw err; + } finally { + logTime(start); + handleSQLErrors(LoggingStatement.this, err); + } + } + + public boolean execute(String sql, String[] sa) throws SQLException { + _sql = sql; + logSQL(this); + long start = System.currentTimeMillis(); + SQLException err = null; + try { + return super.execute(sql, sa); + } catch (SQLException se) { + err = wrap(se, LoggingStatement.this, sql); + throw err; + } finally { + logTime(start); + handleSQLErrors(LoggingStatement.this, err); + } + } } protected abstract class LoggingPreparedStatement @@ -1197,6 +1294,102 @@ public class LoggingConnectionDecorator implements ConnectionDecorator { } } + public int executeUpdate(String s, int i) throws SQLException { + logSQL(this); + long start = System.currentTimeMillis(); + SQLException err = null; + try { + return super.executeUpdate(s, i); + } catch (SQLException se) { + err = wrap(se, LoggingPreparedStatement.this); + throw err; + } finally { + logTime(start); + clearLogParameters(true); + handleSQLErrors(LoggingPreparedStatement.this, err); + } + } + + public int executeUpdate(String s, int[] ia) throws SQLException { + logSQL(this); + long start = System.currentTimeMillis(); + SQLException err = null; + try { + return super.executeUpdate(s, ia); + } catch (SQLException se) { + err = wrap(se, LoggingPreparedStatement.this); + throw err; + } finally { + logTime(start); + clearLogParameters(true); + handleSQLErrors(LoggingPreparedStatement.this, err); + } + } + + public int executeUpdate(String s, String[] sa) throws SQLException { + logSQL(this); + long start = System.currentTimeMillis(); + SQLException err = null; + try { + return super.executeUpdate(s, sa); + } catch (SQLException se) { + err = wrap(se, LoggingPreparedStatement.this); + throw err; + } finally { + logTime(start); + clearLogParameters(true); + handleSQLErrors(LoggingPreparedStatement.this, err); + } + } + + public boolean execute(String s, int i) throws SQLException { + logSQL(this); + long start = System.currentTimeMillis(); + SQLException err = null; + try { + return super.execute(s, i); + } catch (SQLException se) { + err = wrap(se, LoggingPreparedStatement.this); + throw err; + } finally { + logTime(start); + clearLogParameters(true); + handleSQLErrors(LoggingPreparedStatement.this, err); + } + } + + public boolean execute(String s, int[] ia) throws SQLException { + logSQL(this); + long start = System.currentTimeMillis(); + SQLException err = null; + try { + return super.execute(s, ia); + } catch (SQLException se) { + err = wrap(se, LoggingPreparedStatement.this); + throw err; + } finally { + logTime(start); + clearLogParameters(true); + handleSQLErrors(LoggingPreparedStatement.this, err); + } + } + + public boolean execute(String s, String[] sa) throws SQLException { + logSQL(this); + long start = System.currentTimeMillis(); + SQLException err = null; + try { + return super.execute(s, sa); + } catch (SQLException se) { + err = wrap(se, LoggingPreparedStatement.this); + throw err; + } finally { + logTime(start); + clearLogParameters(true); + handleSQLErrors(LoggingPreparedStatement.this, err); + } + } + public void cancel() throws SQLException { if (_logs.isJDBCEnabled()) _logs.logJDBC("cancel " + this + ": " + _sql, @@ -1393,6 +1586,11 @@ public class LoggingConnectionDecorator implements ConnectionDecorator { super.setNull(i1, i2, s); } + public void setURL(int i, URL u) throws SQLException { + setLogParameter(i, "URL", u); + super.setURL(i, u); + } + protected void appendInfo(StringBuffer buf) { buf.append(" "); if (_formatter != null) { @@ -1825,6 +2023,102 @@ public class LoggingConnectionDecorator implements ConnectionDecorator { } } + public int executeUpdate(String s, int i) throws SQLException { + logSQL(this); + long start = System.currentTimeMillis(); + SQLException err = null; + try { + return super.executeUpdate(s, i); + } catch (SQLException se) { + err = wrap(se, LoggingCallableStatement.this); + throw err; + } finally { + logTime(start); + clearLogParameters(true); + handleSQLErrors(LoggingCallableStatement.this, err); + } + } + + public int executeUpdate(String s, int[] ia) throws SQLException { + logSQL(this); + long start = System.currentTimeMillis(); + SQLException err = null; + try { + return super.executeUpdate(s, ia); + } catch (SQLException se) { + err = wrap(se, LoggingCallableStatement.this); + throw err; + } finally { + logTime(start); + clearLogParameters(true); + handleSQLErrors(LoggingCallableStatement.this, err); + } + } + + public int executeUpdate(String s, String[] sa) throws SQLException { + logSQL(this); + long start = System.currentTimeMillis(); + SQLException err = null; + try { + return super.executeUpdate(s, sa); + } catch (SQLException se) { + err = wrap(se, LoggingCallableStatement.this); + throw err; + } finally { + logTime(start); + clearLogParameters(true); + handleSQLErrors(LoggingCallableStatement.this, err); + } + } + + public boolean execute(String s, int i) throws SQLException { + logSQL(this); + long start = System.currentTimeMillis(); + SQLException err = null; + try { + return super.execute(s, i); + } catch (SQLException se) { + err = wrap(se, LoggingCallableStatement.this); + throw err; + } finally { + logTime(start); + clearLogParameters(true); + handleSQLErrors(LoggingCallableStatement.this, err); + } + } + + public boolean execute(String s, int[] ia) throws SQLException { + logSQL(this); + long start = System.currentTimeMillis(); + SQLException err = null; + try { + return super.execute(s, ia); + } catch (SQLException se) { + err = wrap(se, LoggingCallableStatement.this); + throw err; + } finally { + logTime(start); + clearLogParameters(true); + handleSQLErrors(LoggingCallableStatement.this, err); + } + } + + public boolean execute(String s, String[] sa) throws SQLException { + logSQL(this); + long start = System.currentTimeMillis(); + SQLException err = null; + try { + return super.execute(s, sa); + } catch (SQLException se) { + err = wrap(se, LoggingCallableStatement.this); + throw err; + } finally { + logTime(start); + clearLogParameters(true); + handleSQLErrors(LoggingCallableStatement.this, err); + } + } + public void cancel() throws SQLException { if (_logs.isJDBCEnabled()) _logs.logJDBC("cancel " + this + ": " + _sql, @@ -2021,6 +2315,11 @@ public class LoggingConnectionDecorator implements ConnectionDecorator { super.setNull(i1, i2, s); } + public void setURL(int i, URL u) throws SQLException { + setLogParameter(i, "URL", u); + super.setURL(i, u); + } + protected void appendInfo(StringBuffer buf) { buf.append(" "); if (_formatter != null) {