You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pc...@apache.org on 2006/07/01 00:37:29 UTC
svn commit: r418401 [4/32] - in /incubator/openjpa/trunk: openjpa-lib/
openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/
openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/
openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ openjpa-lib/src/m...
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingConnection.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingConnection.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingConnection.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingConnection.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ * 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
@@ -15,64 +12,56 @@
*/
package org.apache.openjpa.lib.jdbc;
-import org.apache.commons.lang.exception.*;
-
-import org.apache.openjpa.lib.util.*;
-import org.apache.openjpa.lib.util.Closeable;
-
-import serp.util.*;
-
import java.io.*;
-
import java.lang.reflect.*;
-
import java.sql.*;
-
import java.util.*;
-
+import org.apache.commons.lang.exception.*;
+import org.apache.openjpa.lib.util.*;
+import org.apache.openjpa.lib.util.Closeable;
+import serp.util.*;
/**
- * <p>Wrapper around an existing connection. Subclasses can override the
- * methods whose behavior they mean to change. The <code>equals</code> and
- * <code>hashCode</code> methods pass through to the base underlying data
- * store connection.</p>
- *
- * @author Abe White
+ * Wrapper around an existing connection. Subclasses can override the
+ * methods whose behavior they mean to change. The <code>equals</code> and
+ * <code>hashCode</code> methods pass through to the base underlying data
+ * store connection.
+ *
+ * @author Abe White
*/
public class DelegatingConnection implements Connection, Closeable {
// jdbc 3 method keys
- private static final Object SET_HOLDABILITY = new Object();
- private static final Object GET_HOLDABILITY = new Object();
- private static final Object SET_SAVEPOINT_NONAME = new Object();
- private static final Object SET_SAVEPOINT = new Object();
- private static final Object ROLLBACK_SAVEPOINT = new Object();
- private static final Object RELEASE_SAVEPOINT = new Object();
- private static final Object CREATE_STATEMENT = new Object();
- private static final Object PREPARE_STATEMENT = new Object();
- private static final Object PREPARE_CALL = new Object();
- private static final Object PREPARE_WITH_KEYS = new Object();
- private static final Object PREPARE_WITH_INDEX = new Object();
- private static final Object PREPARE_WITH_NAMES = new Object();
- private static final Localizer _loc = Localizer.forPackage(DelegatingConnection.class);
- private static final Map _jdbc3;
+ private static final Object SET_HOLDABILITY = new Object();
+ private static final Object GET_HOLDABILITY = new Object();
+ private static final Object SET_SAVEPOINT_NONAME = new Object();
+ private static final Object SET_SAVEPOINT = new Object();
+ private static final Object ROLLBACK_SAVEPOINT = new Object();
+ private static final Object RELEASE_SAVEPOINT = new Object();
+ private static final Object CREATE_STATEMENT = new Object();
+ private static final Object PREPARE_STATEMENT = new Object();
+ private static final Object PREPARE_CALL = new Object();
+ private static final Object PREPARE_WITH_KEYS = new Object();
+ private static final Object PREPARE_WITH_INDEX = new Object();
+ private static final Object PREPARE_WITH_NAMES = new Object();
+ private static final Localizer _loc = Localizer.forPackage
+ (DelegatingConnection.class);
+
+ private static final Map _jdbc3;
static {
boolean jdbc3 = false;
Method m = null;
-
try {
m = Connection.class.getMethod("setSavepoint",
- new Class[] { String.class });
+ new Class[] { String.class });
jdbc3 = true;
- } catch (Throwable t) {
- }
+ } catch (Throwable t) {}
if (jdbc3) {
_jdbc3 = new HashMap();
_jdbc3.put(SET_SAVEPOINT, m);
- } else {
+ } else
_jdbc3 = null;
- }
}
private final Connection _conn;
@@ -80,26 +69,24 @@
public DelegatingConnection(Connection conn) {
_conn = conn;
-
- if (conn instanceof DelegatingConnection) {
+ if (conn instanceof DelegatingConnection)
_del = (DelegatingConnection) _conn;
- } else {
+ else
_del = null;
- }
}
/**
- * Return the wrapped connection.
+ * Return the wrapped connection.
*/
public Connection getDelegate() {
return _conn;
}
/**
- * Return the base underlying data store connection.
+ * Return the base underlying data store connection.
*/
public Connection getInnermostDelegate() {
- return (_del == null) ? _conn : _del.getInnermostDelegate();
+ return(_del == null) ? _conn : _del.getInnermostDelegate();
}
public int hashCode() {
@@ -107,28 +94,22 @@
}
public boolean equals(Object other) {
- if (other == this) {
+ if (other == this)
return true;
- }
-
- if (other instanceof DelegatingConnection) {
+ if (other instanceof DelegatingConnection)
other = ((DelegatingConnection) other).getInnermostDelegate();
- }
-
return getInnermostDelegate().equals(other);
}
public String toString() {
StringBuffer buf = new StringBuffer("conn ").append(hashCode());
appendInfo(buf);
-
return buf.toString();
}
protected void appendInfo(StringBuffer buf) {
- if (_del != null) {
+ if (_del != null)
_del.appendInfo(buf);
- }
}
public Statement createStatement() throws SQLException {
@@ -136,48 +117,37 @@
}
/**
- * Create a statement, with the option of not wrapping it in a
- * {@link DelegatingStatement}, which is the default.
+ * Create a statement, with the option of not wrapping it in a
+ * {@link DelegatingStatement}, which is the default.
*/
protected Statement createStatement(boolean wrap) throws SQLException {
Statement stmnt;
-
- if (_del != null) {
+ if (_del != null)
stmnt = _del.createStatement(false);
- } else {
+ else
stmnt = _conn.createStatement();
- }
-
- if (wrap) {
+ if (wrap)
stmnt = new DelegatingStatement(stmnt, this);
- }
-
return stmnt;
}
- public PreparedStatement prepareStatement(String str)
- throws SQLException {
+ public PreparedStatement prepareStatement(String str) throws SQLException {
return prepareStatement(str, true);
}
/**
- * Prepare a statement, with the option of not wrapping it in a
- * {@link DelegatingPreparedStatement}, which is the default.
+ * Prepare a statement, with the option of not wrapping it in a
+ * {@link DelegatingPreparedStatement}, which is the default.
*/
protected PreparedStatement prepareStatement(String str, boolean wrap)
throws SQLException {
PreparedStatement stmnt;
-
- if (_del != null) {
+ if (_del != null)
stmnt = _del.prepareStatement(str, false);
- } else {
+ else
stmnt = _conn.prepareStatement(str);
- }
-
- if (wrap) {
+ if (wrap)
stmnt = new DelegatingPreparedStatement(stmnt, this);
- }
-
return stmnt;
}
@@ -186,23 +156,18 @@
}
/**
- * Prepare a call, with the option of not wrapping it in a
- * {@link DelegatingCallableStatement}, which is the default.
+ * Prepare a call, with the option of not wrapping it in a
+ * {@link DelegatingCallableStatement}, which is the default.
*/
protected CallableStatement prepareCall(String str, boolean wrap)
throws SQLException {
CallableStatement stmnt;
-
- if (_del != null) {
+ if (_del != null)
stmnt = _del.prepareCall(str, false);
- } else {
+ else
stmnt = _conn.prepareCall(str);
- }
-
- if (wrap) {
+ if (wrap)
stmnt = new DelegatingCallableStatement(stmnt, this);
- }
-
return stmnt;
}
@@ -239,23 +204,17 @@
}
/**
- * Return the metadata, with the option of not wrapping it in a
- * {@link DelegatingDatabaseMetaData}, which is the default.
+ * Return the metadata, with the option of not wrapping it in a
+ * {@link DelegatingDatabaseMetaData}, which is the default.
*/
- protected DatabaseMetaData getMetaData(boolean wrap)
- throws SQLException {
+ protected DatabaseMetaData getMetaData(boolean wrap) throws SQLException {
DatabaseMetaData meta;
-
- if (_del != null) {
+ if (_del != null)
meta = _del.getMetaData(false);
- } else {
+ else
meta = _conn.getMetaData();
- }
-
- if (wrap) {
+ if (wrap)
meta = new DelegatingDatabaseMetaData(meta, this);
- }
-
return meta;
}
@@ -291,29 +250,23 @@
_conn.clearWarnings();
}
- public Statement createStatement(int type, int concur)
- throws SQLException {
+ public Statement createStatement(int type, int concur) throws SQLException {
return createStatement(type, concur, true);
}
/**
- * Create a statement, with the option of not wrapping it in a
- * {@link DelegatingStatement}, which is the default.
+ * Create a statement, with the option of not wrapping it in a
+ * {@link DelegatingStatement}, which is the default.
*/
protected Statement createStatement(int type, int concur, boolean wrap)
throws SQLException {
Statement stmnt;
-
- if (_del != null) {
+ if (_del != null)
stmnt = _del.createStatement(type, concur, false);
- } else {
+ else
stmnt = _conn.createStatement(type, concur);
- }
-
- if (wrap) {
+ if (wrap)
stmnt = new DelegatingStatement(stmnt, this);
- }
-
return stmnt;
}
@@ -323,23 +276,18 @@
}
/**
- * Prepare a statement, with the option of not wrapping it in a
- * {@link DelegatingPreparedStatement}, which is the default.
+ * Prepare a statement, with the option of not wrapping it in a
+ * {@link DelegatingPreparedStatement}, which is the default.
*/
protected PreparedStatement prepareStatement(String str, int type,
int concur, boolean wrap) throws SQLException {
PreparedStatement stmnt;
-
- if (_del != null) {
+ if (_del != null)
stmnt = _del.prepareStatement(str, type, concur, false);
- } else {
+ else
stmnt = _conn.prepareStatement(str, type, concur);
- }
-
- if (wrap) {
+ if (wrap)
stmnt = new DelegatingPreparedStatement(stmnt, this);
- }
-
return stmnt;
}
@@ -349,23 +297,18 @@
}
/**
- * Prepare a call, with the option of not wrapping it in a
- * {@link DelegatingCallableStatement}, which is the default.
+ * Prepare a call, with the option of not wrapping it in a
+ * {@link DelegatingCallableStatement}, which is the default.
*/
protected CallableStatement prepareCall(String str, int type, int concur,
boolean wrap) throws SQLException {
CallableStatement stmnt;
-
- if (_del != null) {
+ if (_del != null)
stmnt = _del.prepareCall(str, type, concur, false);
- } else {
+ else
stmnt = _conn.prepareCall(str, type, concur);
- }
-
- if (wrap) {
+ if (wrap)
stmnt = new DelegatingCallableStatement(stmnt, this);
- }
-
return stmnt;
}
@@ -377,90 +320,65 @@
_conn.setTypeMap(map);
}
- // JDBC 3.0 methods follow; these are required to be able to
+ // JDBC 3.0 methods follow; these are required to be able to
// compile against JDK 1.4; these methods will not work on
// previous JVMs
+
public void setHoldability(int holdability) throws SQLException {
assertJDBC3();
-
Method m = (Method) _jdbc3.get(SET_HOLDABILITY);
-
- if (m == null) {
+ if (m == null)
m = createJDBC3Method(SET_HOLDABILITY, "setHoldability",
- new Class[] { int.class });
- }
-
- invokeJDBC3(m, new Object[] { Numbers.valueOf(holdability) });
+ new Class[] {int.class});
+ invokeJDBC3(m, new Object[] {Numbers.valueOf(holdability)});
}
public int getHoldability() throws SQLException {
assertJDBC3();
-
Method m = (Method) _jdbc3.get(GET_HOLDABILITY);
-
- if (m == null) {
+ if (m == null)
m = createJDBC3Method(GET_HOLDABILITY, "getHoldability", null);
- }
-
- return ((Number) invokeJDBC3(m, null)).intValue();
+ return((Number) invokeJDBC3(m, null)).intValue();
}
public Savepoint setSavepoint() throws SQLException {
assertJDBC3();
-
Method m = (Method) _jdbc3.get(SET_SAVEPOINT_NONAME);
-
- if (m == null) {
+ if (m == null)
m = createJDBC3Method(SET_SAVEPOINT_NONAME, "setSavepoint", null);
- }
-
- return (Savepoint) invokeJDBC3(m, null);
+ return(Savepoint) invokeJDBC3(m, null);
}
public Savepoint setSavepoint(String savepoint) throws SQLException {
assertJDBC3();
-
Method m = (Method) _jdbc3.get(SET_SAVEPOINT);
-
- if (m == null) {
+ if (m == null)
m = createJDBC3Method(SET_SAVEPOINT, "setSavepoint",
- new Class[] { String.class });
- }
-
- return (Savepoint) invokeJDBC3(m, new Object[] { savepoint });
+ new Class[] {String.class});
+ return(Savepoint) invokeJDBC3(m, new Object[] {savepoint});
}
public void rollback(Savepoint savepoint) throws SQLException {
assertJDBC3();
-
Method m = (Method) _jdbc3.get(ROLLBACK_SAVEPOINT);
-
- if (m == null) {
+ if (m == null)
m = createJDBC3Method(ROLLBACK_SAVEPOINT, "rollback",
- new Class[] { Savepoint.class });
- }
-
- invokeJDBC3(m, new Object[] { savepoint });
+ new Class[] {Savepoint.class});
+ invokeJDBC3(m, new Object[] {savepoint});
}
public void releaseSavepoint(Savepoint savepoint) throws SQLException {
assertJDBC3();
-
Method m = (Method) _jdbc3.get(RELEASE_SAVEPOINT);
-
- if (m == null) {
+ if (m == null)
m = createJDBC3Method(RELEASE_SAVEPOINT, "releaseSavepoint",
- new Class[] { Savepoint.class });
- }
-
- invokeJDBC3(m, new Object[] { savepoint });
+ new Class[] {Savepoint.class});
+ invokeJDBC3(m, new Object[] {savepoint});
}
public Statement createStatement(int resultSetType,
- int resultSetConcurrency, int resultSetHoldability)
- throws SQLException {
+ int resultSetConcurrency, int resultSetHoldability) throws SQLException {
assertJDBC3();
-
return createStatement(resultSetType, resultSetConcurrency,
resultSetHoldability, true);
}
@@ -469,80 +387,58 @@
int resultSetConcurrency, int resultSetHoldability, boolean wrap)
throws SQLException {
Statement stmnt;
-
- if (_del != null) {
+ if (_del != null)
stmnt = _del.createStatement(resultSetType, resultSetConcurrency,
- resultSetHoldability, false);
- } else {
+ resultSetHoldability, false);
+ else {
Method m = (Method) _jdbc3.get(CREATE_STATEMENT);
-
- if (m == null) {
+ if (m == null)
m = createJDBC3Method(CREATE_STATEMENT, "createStatement",
- new Class[] { int.class, int.class, int.class });
- }
-
- stmnt = (Statement) invokeJDBC3(m,
- new Object[] {
- Numbers.valueOf(resultSetType),
- Numbers.valueOf(resultSetConcurrency),
- Numbers.valueOf(resultSetHoldability)
- });
+ new Class[] {int.class, int.class, int.class});
+ stmnt = (Statement) invokeJDBC3(m, new Object[] {
+ Numbers.valueOf(resultSetType),
+ Numbers.valueOf(resultSetConcurrency),
+ Numbers.valueOf(resultSetHoldability)});
}
-
- if (wrap) {
+ if (wrap)
stmnt = new DelegatingStatement(stmnt, this);
- }
-
return stmnt;
}
- public PreparedStatement prepareStatement(String sql, int resultSetType,
- int resultSetConcurrency, int resultSetHoldability)
+ public PreparedStatement prepareStatement(String sql,
+ int resultSetType, int resultSetConcurrency, int resultSetHoldability)
throws SQLException {
assertJDBC3();
-
return prepareStatement(sql, resultSetType, resultSetConcurrency,
resultSetHoldability, true);
}
- protected PreparedStatement prepareStatement(String sql, int resultSetType,
- int resultSetConcurrency, int resultSetHoldability, boolean wrap)
- throws SQLException {
+ protected PreparedStatement prepareStatement(String sql,
+ int resultSetType, int resultSetConcurrency, int resultSetHoldability,
+ boolean wrap) throws SQLException {
PreparedStatement stmnt;
-
- if (_del != null) {
+ if (_del != null)
stmnt = _del.prepareStatement(sql, resultSetType,
- resultSetConcurrency, resultSetHoldability, false);
- } else {
+ resultSetConcurrency, resultSetHoldability, false);
+ else {
Method m = (Method) _jdbc3.get(PREPARE_STATEMENT);
-
- if (m == null) {
+ if (m == null)
m = createJDBC3Method(PREPARE_STATEMENT, "prepareStatement",
- new Class[] {
- String.class, int.class, int.class, int.class
- });
- }
-
- stmnt = (PreparedStatement) invokeJDBC3(m,
- new Object[] {
- sql, Numbers.valueOf(resultSetType),
- Numbers.valueOf(resultSetConcurrency),
- Numbers.valueOf(resultSetHoldability)
- });
+ new Class[]{String.class, int.class, int.class, int.class});
+ stmnt = (PreparedStatement) invokeJDBC3(m, new Object[] { sql,
+ Numbers.valueOf(resultSetType),
+ Numbers.valueOf(resultSetConcurrency),
+ Numbers.valueOf(resultSetHoldability)});
}
-
- if (wrap) {
+ if (wrap)
stmnt = new DelegatingPreparedStatement(stmnt, this);
- }
-
return stmnt;
}
- public CallableStatement prepareCall(String sql, int resultSetType,
- int resultSetConcurrency, int resultSetHoldability)
+ public CallableStatement prepareCall(String sql,
+ int resultSetType, int resultSetConcurrency, int resultSetHoldability)
throws SQLException {
assertJDBC3();
-
return prepareCall(sql, resultSetType, resultSetConcurrency,
resultSetHoldability, true);
}
@@ -551,148 +447,108 @@
int resultSetConcurrency, int resultSetHoldability, boolean wrap)
throws SQLException {
CallableStatement stmnt;
-
- if (_del != null) {
- stmnt = _del.prepareCall(sql, resultSetType, resultSetConcurrency,
- resultSetHoldability, false);
- } else {
+ if (_del != null)
+ stmnt = _del.prepareCall(sql, resultSetType,
+ resultSetConcurrency, resultSetHoldability, false);
+ else {
Method m = (Method) _jdbc3.get(PREPARE_CALL);
-
- if (m == null) {
+ if (m == null)
m = createJDBC3Method(PREPARE_CALL, "prepareCall",
- new Class[] {
- String.class, int.class, int.class, int.class
- });
- }
-
- stmnt = (CallableStatement) invokeJDBC3(m,
- new Object[] {
- sql, Numbers.valueOf(resultSetType),
- Numbers.valueOf(resultSetConcurrency),
- Numbers.valueOf(resultSetHoldability)
- });
+ new Class[]{String.class, int.class, int.class, int.class});
+ stmnt = (CallableStatement) invokeJDBC3(m, new Object[] { sql,
+ Numbers.valueOf(resultSetType),
+ Numbers.valueOf(resultSetConcurrency),
+ Numbers.valueOf(resultSetHoldability)});
}
-
- if (wrap) {
+ if (wrap)
stmnt = new DelegatingCallableStatement(stmnt, this);
- }
-
return stmnt;
}
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
throws SQLException {
assertJDBC3();
-
return prepareStatement(sql, autoGeneratedKeys, true);
}
protected PreparedStatement prepareStatement(String sql,
int autoGeneratedKeys, boolean wrap) throws SQLException {
PreparedStatement stmnt;
-
- if (_del != null) {
+ if (_del != null)
stmnt = _del.prepareStatement(sql, autoGeneratedKeys);
- } else {
+ else {
Method m = (Method) _jdbc3.get(PREPARE_WITH_KEYS);
-
- if (m == null) {
+ if (m == null)
m = createJDBC3Method(PREPARE_WITH_KEYS, "prepareStatement",
- new Class[] { String.class, int.class });
- }
-
- stmnt = (PreparedStatement) invokeJDBC3(m,
- new Object[] { sql, Numbers.valueOf(autoGeneratedKeys) });
+ new Class[] {String.class, int.class});
+ stmnt = (PreparedStatement) invokeJDBC3(m, new Object[] { sql,
+ Numbers.valueOf(autoGeneratedKeys)});
}
-
- if (wrap) {
+ if (wrap)
stmnt = new DelegatingPreparedStatement(stmnt, this);
- }
-
return stmnt;
}
public PreparedStatement prepareStatement(String sql, int[] columnIndexes)
throws SQLException {
assertJDBC3();
-
return prepareStatement(sql, columnIndexes, true);
}
protected PreparedStatement prepareStatement(String sql,
int[] columnIndexes, boolean wrap) throws SQLException {
PreparedStatement stmnt;
-
- if (_del != null) {
+ if (_del != null)
stmnt = _del.prepareStatement(sql, columnIndexes, wrap);
- } else {
+ else {
Method m = (Method) _jdbc3.get(PREPARE_WITH_INDEX);
-
- if (m == null) {
+ if (m == null)
m = createJDBC3Method(PREPARE_WITH_INDEX, "prepareStatement",
- new Class[] { String.class, int[].class });
- }
-
- stmnt = (PreparedStatement) invokeJDBC3(m,
- new Object[] { sql, columnIndexes });
+ new Class[] {String.class, int[].class});
+ stmnt = (PreparedStatement) invokeJDBC3(m, new Object[] { sql,
+ columnIndexes});
}
-
- if (wrap) {
+ if (wrap)
stmnt = new DelegatingPreparedStatement(stmnt, this);
- }
-
return stmnt;
}
public PreparedStatement prepareStatement(String sql, String[] columnNames)
throws SQLException {
assertJDBC3();
-
return prepareStatement(sql, columnNames, true);
}
protected PreparedStatement prepareStatement(String sql,
String[] columnNames, boolean wrap) throws SQLException {
assertJDBC3();
-
PreparedStatement stmnt;
-
- if (_del != null) {
+ if (_del != null)
stmnt = _del.prepareStatement(sql, columnNames, wrap);
- } else {
+ else {
Method m = (Method) _jdbc3.get(PREPARE_WITH_NAMES);
-
- if (m == null) {
+ if (m == null)
m = createJDBC3Method(PREPARE_WITH_NAMES, "prepareStatement",
- new Class[] { String.class, String[].class });
- }
-
- stmnt = (PreparedStatement) invokeJDBC3(m,
- new Object[] { sql, columnNames });
+ new Class[] {String.class, String[].class});
+ stmnt = (PreparedStatement) invokeJDBC3(m, new Object[] { sql,
+ columnNames});
}
-
- if (wrap) {
+ if (wrap)
stmnt = new DelegatingPreparedStatement(stmnt, this);
- }
-
return stmnt;
}
private static void assertJDBC3() {
- if (_jdbc3 == null) {
+ if (_jdbc3 == null)
throw new UnsupportedOperationException(_loc.get("not-jdbc3"));
- }
}
- private Object invokeJDBC3(Method m, Object[] args)
- throws SQLException {
+ private Object invokeJDBC3(Method m, Object[] args) throws SQLException {
try {
return m.invoke(_conn, args);
} catch (Throwable t) {
- if (t instanceof SQLException) {
- throw (SQLException) t;
- }
-
+ if (t instanceof SQLException)
+ throw(SQLException) t;
throw new NestableRuntimeException(_loc.get("invoke-jdbc3"), t);
}
}
@@ -702,7 +558,6 @@
try {
Method m = Connection.class.getMethod(name, args);
_jdbc3.put(key, m);
-
return m;
} catch (Throwable t) {
throw new NestableRuntimeException(_loc.get("error-jdbc3"), t);
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ * 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
@@ -15,53 +12,47 @@
*/
package org.apache.openjpa.lib.jdbc;
-import org.apache.openjpa.lib.util.*;
-import org.apache.openjpa.lib.util.Closeable;
-
import java.io.*;
-
import java.sql.*;
-
import javax.sql.*;
-
+import org.apache.openjpa.lib.util.*;
+import org.apache.openjpa.lib.util.Closeable;
/**
- * <p>Wrapper around an existing data source. Subclasses can override the
- * methods whose behavior they mean to change. The <code>equals</code> and
- * <code>hashCode</code> methods pass through to the base underlying data
- * store.</p>
- *
- * @author Abe White
+ * Wrapper around an existing data source. Subclasses can override the
+ * methods whose behavior they mean to change. The <code>equals</code> and
+ * <code>hashCode</code> methods pass through to the base underlying data store.
+ *
+ * @author Abe White
*/
public class DelegatingDataSource implements DataSource, Closeable {
private final DataSource _ds;
private final DelegatingDataSource _del;
/**
- * Constructor. Supply wrapped data source.
+ * Constructor. Supply wrapped data source.
*/
public DelegatingDataSource(DataSource ds) {
_ds = ds;
- if (_ds instanceof DelegatingDataSource) {
+ if (_ds instanceof DelegatingDataSource)
_del = (DelegatingDataSource) _ds;
- } else {
+ else
_del = null;
- }
}
/**
- * Return the wrapped data source.
+ * Return the wrapped data source.
*/
public DataSource getDelegate() {
return _ds;
}
/**
- * Return the inner-most wrapped delegate.
+ * Return the inner-most wrapped delegate.
*/
public DataSource getInnermostDelegate() {
- return (_del == null) ? _ds : _del.getInnermostDelegate();
+ return(_del == null) ? _ds : _del.getInnermostDelegate();
}
public int hashCode() {
@@ -69,28 +60,22 @@
}
public boolean equals(Object other) {
- if (other == this) {
+ if (other == this)
return true;
- }
-
- if (other instanceof DelegatingDataSource) {
+ if (other instanceof DelegatingDataSource)
other = ((DelegatingDataSource) other).getInnermostDelegate();
- }
-
return getInnermostDelegate().equals(other);
}
public String toString() {
- StringBuffer buf = new StringBuffer("datasource ").append(hashCode());
+ StringBuffer buf = new StringBuffer("datasource "). append(hashCode());
appendInfo(buf);
-
return buf.toString();
}
protected void appendInfo(StringBuffer buf) {
- if (_del != null) {
+ if (_del != null)
_del.appendInfo(buf);
- }
}
public PrintWriter getLogWriter() throws SQLException {
@@ -115,16 +100,13 @@
public Connection getConnection(String user, String pass)
throws SQLException {
- if ((user == null) && (pass == null)) {
+ if (user == null && pass == null)
return _ds.getConnection();
- }
-
return _ds.getConnection(user, pass);
}
public void close() throws Exception {
- if (_ds instanceof Closeable) {
+ if (_ds instanceof Closeable)
((Closeable) _ds).close();
- }
}
}
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDatabaseMetaData.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDatabaseMetaData.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDatabaseMetaData.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDatabaseMetaData.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ * 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
@@ -16,33 +13,31 @@
package org.apache.openjpa.lib.jdbc;
import java.io.*;
-
import java.sql.*;
-
import java.util.*;
-
/**
- * <p>Wrapper around a DatabaseMetadata instance.</p>
- *
- * @author Marc Prud'hommeaux
+ * Wrapper around a DatabaseMetadata instance.
+ *
+ * @author Marc Prud'hommeaux
*/
public class DelegatingDatabaseMetaData implements DatabaseMetaData {
private final DatabaseMetaData _metaData;
- private final Connection _conn;
+ private final Connection _conn;
- public DelegatingDatabaseMetaData(DatabaseMetaData metaData, Connection conn) {
+ public DelegatingDatabaseMetaData(DatabaseMetaData metaData,
+ Connection conn) {
_conn = conn;
_metaData = metaData;
}
/**
- * Return the base underlying database metadata.
+ * Return the base underlying database metadata.
*/
public DatabaseMetaData getInnermostDelegate() {
- return (_metaData instanceof DelegatingDatabaseMetaData)
- ? ((DelegatingDatabaseMetaData) _metaData).getInnermostDelegate()
- : _metaData;
+ return _metaData instanceof DelegatingDatabaseMetaData ?
+ ((DelegatingDatabaseMetaData)_metaData).getInnermostDelegate()
+ : _metaData;
}
public int hashCode() {
@@ -50,21 +45,17 @@
}
public boolean equals(Object other) {
- if (other == this) {
+ if (other == this)
return true;
- }
-
- if (other instanceof DelegatingDatabaseMetaData) {
- other = ((DelegatingDatabaseMetaData) other).getInnermostDelegate();
- }
-
+ if (other instanceof DelegatingDatabaseMetaData)
+ other = ((DelegatingDatabaseMetaData) other)
+ .getInnermostDelegate();
return getInnermostDelegate().equals(other);
}
public String toString() {
StringBuffer buf = new StringBuffer("metadata ").append(hashCode());
buf.append("[").append(_metaData.toString()).append("]");
-
return buf.toString();
}
@@ -76,13 +67,11 @@
return _metaData.allTablesAreSelectable();
}
- public boolean dataDefinitionCausesTransactionCommit()
- throws SQLException {
+ public boolean dataDefinitionCausesTransactionCommit() throws SQLException {
return _metaData.dataDefinitionCausesTransactionCommit();
}
- public boolean dataDefinitionIgnoredInTransactions()
- throws SQLException {
+ public boolean dataDefinitionIgnoredInTransactions() throws SQLException {
return _metaData.dataDefinitionIgnoredInTransactions();
}
@@ -94,10 +83,11 @@
return _metaData.doesMaxRowSizeIncludeBlobs();
}
- public ResultSet getBestRowIdentifier(String catalog, String schema,
- String table, int scope, boolean nullable) throws SQLException {
- return _metaData.getBestRowIdentifier(catalog, schema, table, scope,
- nullable);
+ public ResultSet getBestRowIdentifier(String catalog,
+ String schema, String table, int scope, boolean nullable)
+ throws SQLException {
+ return _metaData.getBestRowIdentifier(catalog, schema,
+ table, scope, nullable);
}
public ResultSet getCatalogs() throws SQLException {
@@ -114,15 +104,14 @@
public ResultSet getColumnPrivileges(String catalog, String schema,
String table, String columnNamePattern) throws SQLException {
- return _metaData.getColumnPrivileges(catalog, schema, table,
- columnNamePattern);
+ return _metaData.getColumnPrivileges(catalog, schema,
+ table, columnNamePattern);
}
public ResultSet getColumns(String catalog, String schemaPattern,
- String tableNamePattern, String columnNamePattern)
- throws SQLException {
- return _metaData.getColumns(catalog, schemaPattern, tableNamePattern,
- columnNamePattern);
+ String tableNamePattern, String columnNamePattern) throws SQLException {
+ return _metaData.getColumns(catalog, schemaPattern,
+ tableNamePattern, columnNamePattern);
}
public Connection getConnection() throws SQLException {
@@ -164,8 +153,8 @@
return _metaData.getDriverVersion();
}
- public ResultSet getExportedKeys(String catalog, String schema, String table)
- throws SQLException {
+ public ResultSet getExportedKeys(String catalog, String schema,
+ String table) throws SQLException {
return _metaData.getExportedKeys(catalog, schema, table);
}
@@ -177,13 +166,13 @@
return _metaData.getIdentifierQuoteString();
}
- public ResultSet getImportedKeys(String catalog, String schema, String table)
- throws SQLException {
+ public ResultSet getImportedKeys(String catalog, String schema,
+ String table) throws SQLException {
return _metaData.getImportedKeys(catalog, schema, table);
}
- public ResultSet getIndexInfo(String catalog, String schema, String table,
- boolean unique, boolean approximate) throws SQLException {
+ public ResultSet getIndexInfo(String catalog, String schema,
+ String table, boolean unique, boolean approximate) throws SQLException {
return _metaData.getIndexInfo(catalog, schema, table, unique,
approximate);
}
@@ -318,16 +307,16 @@
return _metaData.getSystemFunctions();
}
- public ResultSet getTablePrivileges(String catalog, String schemaPattern,
- String tableNamePattern) throws SQLException {
+ public ResultSet getTablePrivileges(String catalog,
+ String schemaPattern, String tableNamePattern) throws SQLException {
return _metaData.getTablePrivileges(catalog, schemaPattern,
tableNamePattern);
}
public ResultSet getTables(String catalog, String schemaPattern,
String tableNamePattern, String[] types) throws SQLException {
- return _metaData.getTables(catalog, schemaPattern, tableNamePattern,
- types);
+ return _metaData.getTables(catalog, schemaPattern,
+ tableNamePattern, types);
}
public ResultSet getTableTypes() throws SQLException {
@@ -344,7 +333,8 @@
public ResultSet getUDTs(String catalog, String schemaPattern,
String typeNamePattern, int[] types) throws SQLException {
- return _metaData.getUDTs(catalog, schemaPattern, typeNamePattern, types);
+ return _metaData.getUDTs(catalog, schemaPattern,
+ typeNamePattern, types);
}
public String getURL() throws SQLException {
@@ -355,8 +345,8 @@
return _metaData.getUserName();
}
- public ResultSet getVersionColumns(String catalog, String schema,
- String table) throws SQLException {
+ public ResultSet getVersionColumns(String catalog,
+ String schema, String table) throws SQLException {
return _metaData.getVersionColumns(catalog, schema, table);
}
@@ -464,18 +454,15 @@
return _metaData.supportsBatchUpdates();
}
- public boolean supportsCatalogsInDataManipulation()
- throws SQLException {
+ public boolean supportsCatalogsInDataManipulation() throws SQLException {
return _metaData.supportsCatalogsInDataManipulation();
}
- public boolean supportsCatalogsInIndexDefinitions()
- throws SQLException {
+ public boolean supportsCatalogsInIndexDefinitions() throws SQLException {
return _metaData.supportsCatalogsInIndexDefinitions();
}
- public boolean supportsCatalogsInPrivilegeDefinitions()
- throws SQLException {
+ public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException {
return _metaData.supportsCatalogsInPrivilegeDefinitions();
}
@@ -483,8 +470,7 @@
return _metaData.supportsCatalogsInProcedureCalls();
}
- public boolean supportsCatalogsInTableDefinitions()
- throws SQLException {
+ public boolean supportsCatalogsInTableDefinitions() throws SQLException {
return _metaData.supportsCatalogsInTableDefinitions();
}
@@ -496,8 +482,7 @@
return _metaData.supportsConvert();
}
- public boolean supportsConvert(int fromType, int toType)
- throws SQLException {
+ public boolean supportsConvert(int fromType, int toType) throws SQLException {
return _metaData.supportsConvert(fromType, toType);
}
@@ -511,7 +496,8 @@
public boolean supportsDataDefinitionAndDataManipulationTransactions()
throws SQLException {
- return _metaData.supportsDataDefinitionAndDataManipulationTransactions();
+ return _metaData
+ .supportsDataDefinitionAndDataManipulationTransactions();
}
public boolean supportsDataManipulationTransactionsOnly()
@@ -519,8 +505,7 @@
return _metaData.supportsDataManipulationTransactionsOnly();
}
- public boolean supportsDifferentTableCorrelationNames()
- throws SQLException {
+ public boolean supportsDifferentTableCorrelationNames() throws SQLException {
return _metaData.supportsDifferentTableCorrelationNames();
}
@@ -548,8 +533,7 @@
return _metaData.supportsGroupByUnrelated();
}
- public boolean supportsIntegrityEnhancementFacility()
- throws SQLException {
+ public boolean supportsIntegrityEnhancementFacility() throws SQLException {
return _metaData.supportsIntegrityEnhancementFacility();
}
@@ -569,8 +553,7 @@
return _metaData.supportsMixedCaseIdentifiers();
}
- public boolean supportsMixedCaseQuotedIdentifiers()
- throws SQLException {
+ public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
return _metaData.supportsMixedCaseQuotedIdentifiers();
}
@@ -590,18 +573,15 @@
return _metaData.supportsOpenCursorsAcrossCommit();
}
- public boolean supportsOpenCursorsAcrossRollback()
- throws SQLException {
+ public boolean supportsOpenCursorsAcrossRollback() throws SQLException {
return _metaData.supportsOpenCursorsAcrossRollback();
}
- public boolean supportsOpenStatementsAcrossCommit()
- throws SQLException {
+ public boolean supportsOpenStatementsAcrossCommit() throws SQLException {
return _metaData.supportsOpenStatementsAcrossCommit();
}
- public boolean supportsOpenStatementsAcrossRollback()
- throws SQLException {
+ public boolean supportsOpenStatementsAcrossRollback() throws SQLException {
return _metaData.supportsOpenStatementsAcrossRollback();
}
@@ -630,18 +610,15 @@
return _metaData.supportsResultSetType(type);
}
- public boolean supportsSchemasInDataManipulation()
- throws SQLException {
+ public boolean supportsSchemasInDataManipulation() throws SQLException {
return _metaData.supportsSchemasInDataManipulation();
}
- public boolean supportsSchemasInIndexDefinitions()
- throws SQLException {
+ public boolean supportsSchemasInIndexDefinitions() throws SQLException {
return _metaData.supportsSchemasInIndexDefinitions();
}
- public boolean supportsSchemasInPrivilegeDefinitions()
- throws SQLException {
+ public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException {
return _metaData.supportsSchemasInPrivilegeDefinitions();
}
@@ -649,8 +626,7 @@
return _metaData.supportsSchemasInProcedureCalls();
}
- public boolean supportsSchemasInTableDefinitions()
- throws SQLException {
+ public boolean supportsSchemasInTableDefinitions() throws SQLException {
return _metaData.supportsSchemasInTableDefinitions();
}
@@ -711,8 +687,9 @@
return _metaData.usesLocalFiles();
}
- // JDBC 3.0 methods (unsupported) follow; these are required to be able to
+ // JDBC 3.0 methods(unsupported) follow; these are required to be able to
// compile against JDK 1.4
+
public boolean supportsSavepoints() throws SQLException {
throw new UnsupportedOperationException();
}
@@ -740,8 +717,7 @@
}
public ResultSet getAttributes(String catalog, String schemaPatter,
- String typeNamePattern, String attributeNamePattern)
- throws SQLException {
+ String typeNamePattern, String attributeNamePattern) throws SQLException {
throw new UnsupportedOperationException();
}
@@ -782,3 +758,4 @@
throw new UnsupportedOperationException();
}
}
+
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingPreparedStatement.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingPreparedStatement.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingPreparedStatement.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingPreparedStatement.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ * 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
@@ -15,31 +12,24 @@
*/
package org.apache.openjpa.lib.jdbc;
-import org.apache.openjpa.lib.util.*;
-import org.apache.openjpa.lib.util.Closeable;
-
import java.io.*;
-
import java.math.*;
-
import java.net.*;
-
import java.sql.*;
import java.sql.Date;
-
import java.util.*;
-
+import org.apache.openjpa.lib.util.*;
+import org.apache.openjpa.lib.util.Closeable;
/**
- * <p>Wrapper around an existing statement. Subclasses can override the
- * methods whose behavior they mean to change. The <code>equals</code> and
- * <code>hashCode</code> methods pass through to the base underlying data
- * store statement.</p>
- *
- * @author Abe White
+ * Wrapper around an existing statement. Subclasses can override the
+ * methods whose behavior they mean to change. The <code>equals</code> and
+ * <code>hashCode</code> methods pass through to the base underlying data
+ * store statement.
+ *
+ * @author Abe White
*/
-public class DelegatingPreparedStatement implements PreparedStatement,
- Closeable {
+public class DelegatingPreparedStatement implements PreparedStatement, Closeable {
private final PreparedStatement _stmnt;
private final DelegatingPreparedStatement _del;
private final Connection _conn;
@@ -47,34 +37,30 @@
public DelegatingPreparedStatement(PreparedStatement stmnt, Connection conn) {
_conn = conn;
_stmnt = stmnt;
-
- if (_stmnt instanceof DelegatingPreparedStatement) {
+ if (_stmnt instanceof DelegatingPreparedStatement)
_del = (DelegatingPreparedStatement) _stmnt;
- } else {
+ else
_del = null;
- }
}
protected ResultSet wrapResult(ResultSet rs, boolean wrap) {
- if (!wrap || (rs == null)) {
+ if (!wrap || rs == null)
return rs;
- }
-
return new DelegatingResultSet(rs, this);
}
/**
- * Return the wrapped statement.
+ * Return the wrapped statement.
*/
public PreparedStatement getDelegate() {
return _stmnt;
}
/**
- * Return the base underlying data store statement.
+ * Return the base underlying data store statement.
*/
public PreparedStatement getInnermostDelegate() {
- return (_del == null) ? _stmnt : _del.getInnermostDelegate();
+ return(_del == null) ? _stmnt : _del.getInnermostDelegate();
}
public int hashCode() {
@@ -82,28 +68,23 @@
}
public boolean equals(Object other) {
- if (other == this) {
+ if (other == this)
return true;
- }
-
- if (other instanceof DelegatingPreparedStatement) {
- other = ((DelegatingPreparedStatement) other).getInnermostDelegate();
- }
-
+ if (other instanceof DelegatingPreparedStatement)
+ other = ((DelegatingPreparedStatement) other).
+ getInnermostDelegate();
return getInnermostDelegate().equals(other);
}
public String toString() {
StringBuffer buf = new StringBuffer("prepstmnt ").append(hashCode());
appendInfo(buf);
-
return buf.toString();
}
protected void appendInfo(StringBuffer buf) {
- if (_del != null) {
+ if (_del != null)
_del.appendInfo(buf);
- }
}
public ResultSet executeQuery(String str) throws SQLException {
@@ -111,19 +92,16 @@
}
/**
- * Execute the query, with the option of not wrapping it in a
- * {@link DelegatingResultSet}, which is the default.
+ * Execute the query, with the option of not wrapping it in a
+ * {@link DelegatingResultSet}, which is the default.
*/
protected ResultSet executeQuery(String sql, boolean wrap)
throws SQLException {
ResultSet rs;
-
- if (_del != null) {
+ if (_del != null)
rs = _del.executeQuery(sql, false);
- } else {
+ else
rs = _stmnt.executeQuery(sql);
- }
-
return wrapResult(rs, wrap);
}
@@ -188,18 +166,15 @@
}
/**
- * Get the last result set, with the option of not wrapping it in a
- * {@link DelegatingResultSet}, which is the default.
+ * Get the last result set, with the option of not wrapping it in a
+ * {@link DelegatingResultSet}, which is the default.
*/
protected ResultSet getResultSet(boolean wrap) throws SQLException {
ResultSet rs;
-
- if (_del != null) {
+ if (_del != null)
rs = _del.getResultSet(false);
- } else {
+ else
rs = _stmnt.getResultSet();
- }
-
return wrapResult(rs, wrap);
}
@@ -256,22 +231,19 @@
}
/**
- * Execute the query, with the option of not wrapping it in a
- * {@link DelegatingResultSet}, which is the default.
+ * Execute the query, with the option of not wrapping it in a
+ * {@link DelegatingResultSet}, which is the default.
*/
protected ResultSet executeQuery(boolean wrap) throws SQLException {
ResultSet rs;
-
- if (_del != null) {
+ if (_del != null)
rs = _del.executeQuery(false);
- } else {
+ else
rs = _stmnt.executeQuery();
- }
-
return wrapResult(rs, wrap);
}
- public int executeUpdate() throws SQLException {
+ public int executeUpdate () throws SQLException {
return _stmnt.executeUpdate();
}
@@ -350,8 +322,7 @@
_stmnt.clearParameters();
}
- public void setObject(int i1, Object o, int i2, int i3)
- throws SQLException {
+ public void setObject(int i1, Object o, int i2, int i3) throws SQLException {
_stmnt.setObject(i1, o, i2, i3);
}
@@ -371,8 +342,7 @@
_stmnt.addBatch();
}
- public void setCharacterStream(int i1, Reader r, int i2)
- throws SQLException {
+ public void setCharacterStream(int i1, Reader r, int i2) throws SQLException {
_stmnt.setCharacterStream(i1, r, i2);
}
@@ -404,8 +374,7 @@
_stmnt.setTime(i, t, c);
}
- public void setTimestamp(int i, Timestamp t, Calendar c)
- throws SQLException {
+ public void setTimestamp(int i, Timestamp t, Calendar c) throws SQLException {
_stmnt.setTimestamp(i, t, c);
}
@@ -413,8 +382,9 @@
_stmnt.setNull(i1, i2, s);
}
- // JDBC 3.0 (unsupported) method follow; these are required to be able
+ // JDBC 3.0 (unsupported) method follow; these are required to be able
// to compile against JDK 1.4
+
public boolean getMoreResults(int i) throws SQLException {
throw new UnsupportedOperationException();
}
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ * 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
@@ -15,28 +12,22 @@
*/
package org.apache.openjpa.lib.jdbc;
-import org.apache.openjpa.lib.util.*;
-import org.apache.openjpa.lib.util.Closeable;
-
import java.io.*;
-
import java.math.*;
-
import java.net.*;
-
import java.sql.*;
import java.sql.Date;
-
import java.util.*;
-
+import org.apache.openjpa.lib.util.*;
+import org.apache.openjpa.lib.util.Closeable;
/**
- * <p>Wrapper around an existing result set. Subclasses can override the
- * methods whose behavior they mean to change. The <code>equals</code> and
- * <code>hashCode</code> methods pass through to the base underlying data
- * store statement.</p>
- *
- * @author Marc Prud'hommeaux
+ * Wrapper around an existing result set. Subclasses can override the
+ * methods whose behavior they mean to change. The <code>equals</code> and
+ * <code>hashCode</code> methods pass through to the base underlying data
+ * store statement.
+ *
+ * @author Marc Prud'hommeaux
*/
public class DelegatingResultSet implements ResultSet, Closeable {
private final ResultSet _rs;
@@ -44,32 +35,29 @@
private final Statement _stmnt;
public DelegatingResultSet(ResultSet rs, Statement stmnt) {
- if (rs == null) {
+ if (rs == null)
throw new IllegalArgumentException();
- }
_stmnt = stmnt;
_rs = rs;
-
- if (_rs instanceof DelegatingResultSet) {
+ if (_rs instanceof DelegatingResultSet)
_del = (DelegatingResultSet) _rs;
- } else {
+ else
_del = null;
- }
}
/**
- * Return the wrapped result set.
+ * Return the wrapped result set.
*/
public ResultSet getDelegate() {
return _rs;
}
/**
- * Return the inner-most wrapped delegate.
+ * Return the inner-most wrapped delegate.
*/
public ResultSet getInnermostDelegate() {
- return (_del == null) ? _rs : _del.getInnermostDelegate();
+ return(_del == null) ? _rs : _del.getInnermostDelegate();
}
public int hashCode() {
@@ -77,28 +65,22 @@
}
public boolean equals(Object other) {
- if (other == this) {
+ if (other == this)
return true;
- }
-
- if (other instanceof DelegatingResultSet) {
+ if (other instanceof DelegatingResultSet)
other = ((DelegatingResultSet) other).getInnermostDelegate();
- }
-
return getInnermostDelegate().equals(other);
}
public String toString() {
StringBuffer buf = new StringBuffer("resultset ").append(hashCode());
appendInfo(buf);
-
return buf.toString();
}
protected void appendInfo(StringBuffer buf) {
- if (_del != null) {
+ if (_del != null)
_del.appendInfo(buf);
- }
}
public boolean next() throws SQLException {
@@ -480,8 +462,7 @@
_rs.updateDouble(a, b);
}
- public void updateBigDecimal(String a, BigDecimal b)
- throws SQLException {
+ public void updateBigDecimal(String a, BigDecimal b) throws SQLException {
_rs.updateBigDecimal(a, b);
}
@@ -501,8 +482,7 @@
_rs.updateTime(a, b);
}
- public void updateTimestamp(String a, Timestamp b)
- throws SQLException {
+ public void updateTimestamp(String a, Timestamp b) throws SQLException {
_rs.updateTimestamp(a, b);
}
@@ -521,8 +501,7 @@
_rs.updateCharacterStream(a, reader, b);
}
- public void updateObject(String a, Object ob, int b)
- throws SQLException {
+ public void updateObject(String a, Object ob, int b) throws SQLException {
_rs.updateObject(a, ob, b);
}
@@ -622,13 +601,13 @@
return _rs.getTimestamp(a, b);
}
- public Timestamp getTimestamp(String a, Calendar b)
- throws SQLException {
+ public Timestamp getTimestamp(String a, Calendar b) throws SQLException {
return _rs.getTimestamp(a, b);
}
- // JDBC 3.0 (unsupported) method follow; these are required to be able
+ // JDBC 3.0 (unsupported) method follow; these are required to be able
// to compile against JDK 1.4
+
public URL getURL(int column) throws SQLException {
throw new UnsupportedOperationException();
}
@@ -649,8 +628,7 @@
throw new UnsupportedOperationException();
}
- public void updateBlob(String columnName, Blob blob)
- throws SQLException {
+ public void updateBlob(String columnName, Blob blob) throws SQLException {
throw new UnsupportedOperationException();
}
@@ -658,8 +636,7 @@
throw new UnsupportedOperationException();
}
- public void updateClob(String columnName, Clob clob)
- throws SQLException {
+ public void updateClob(String columnName, Clob clob) throws SQLException {
throw new UnsupportedOperationException();
}
@@ -667,8 +644,8 @@
throw new UnsupportedOperationException();
}
- public void updateArray(String columnName, Array array)
- throws SQLException {
+ public void updateArray(String columnName, Array array) throws SQLException {
throw new UnsupportedOperationException();
}
}
+
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingStatement.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingStatement.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingStatement.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingStatement.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ * 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
@@ -15,18 +12,16 @@
*/
package org.apache.openjpa.lib.jdbc;
-import org.apache.openjpa.lib.util.*;
-
import java.sql.*;
-
+import org.apache.openjpa.lib.util.*;
/**
- * <p>Wrapper around an existing statement. Subclasses can override the
- * methods whose behavior they mean to change. The <code>equals</code> and
- * <code>hashCode</code> methods pass through to the base underlying data
- * store statement.</p>
- *
- * @author Abe White
+ * Wrapper around an existing statement. Subclasses can override the
+ * methods whose behavior they mean to change. The <code>equals</code> and
+ * <code>hashCode</code> methods pass through to the base underlying data
+ * store statement.
+ *
+ * @author Abe White
*/
public class DelegatingStatement implements Statement, Closeable {
private final Statement _stmnt;
@@ -36,34 +31,30 @@
public DelegatingStatement(Statement stmnt, Connection conn) {
_conn = conn;
_stmnt = stmnt;
-
- if (stmnt instanceof DelegatingStatement) {
+ if (stmnt instanceof DelegatingStatement)
_del = (DelegatingStatement) stmnt;
- } else {
+ else
_del = null;
- }
}
protected ResultSet wrapResult(ResultSet rs, boolean wrap) {
- if (!wrap || (rs == null)) {
+ if (!wrap || rs == null)
return rs;
- }
-
return new DelegatingResultSet(rs, this);
}
/**
- * Return the wrapped statement.
+ * Return the wrapped statement.
*/
public Statement getDelegate() {
return _stmnt;
}
/**
- * Return the base underlying data store statement.
+ * Return the base underlying data store statement.
*/
public Statement getInnermostDelegate() {
- return (_del == null) ? _stmnt : _del.getInnermostDelegate();
+ return(_del == null) ? _stmnt : _del.getInnermostDelegate();
}
public int hashCode() {
@@ -71,28 +62,22 @@
}
public boolean equals(Object other) {
- if (other == this) {
+ if (other == this)
return true;
- }
-
- if (other instanceof DelegatingStatement) {
+ if (other instanceof DelegatingStatement)
other = ((DelegatingStatement) other).getInnermostDelegate();
- }
-
return getInnermostDelegate().equals(other);
}
public String toString() {
StringBuffer buf = new StringBuffer("stmnt ").append(hashCode());
appendInfo(buf);
-
return buf.toString();
}
protected void appendInfo(StringBuffer buf) {
- if (_del != null) {
+ if (_del != null)
_del.appendInfo(buf);
- }
}
public ResultSet executeQuery(String str) throws SQLException {
@@ -100,19 +85,16 @@
}
/**
- * Execute the query, with the option of not wrapping it in a
- * {@link DelegatingResultSet}, which is the default.
+ * Execute the query, with the option of not wrapping it in a
+ * {@link DelegatingResultSet}, which is the default.
*/
protected ResultSet executeQuery(String sql, boolean wrap)
throws SQLException {
ResultSet rs;
-
- if (_del != null) {
+ if (_del != null)
rs = _del.executeQuery(sql, false);
- } else {
+ else
rs = _stmnt.executeQuery(sql);
- }
-
return wrapResult(rs, wrap);
}
@@ -177,18 +159,15 @@
}
/**
- * Get the last result set, with the option of not wrapping it in a
- * {@link DelegatingResultSet}, which is the default.
+ * Get the last result set, with the option of not wrapping it in a
+ * {@link DelegatingResultSet}, which is the default.
*/
protected ResultSet getResultSet(boolean wrap) throws SQLException {
ResultSet rs;
-
- if (_del != null) {
+ if (_del != null)
rs = _del.getResultSet(false);
- } else {
+ else
rs = _stmnt.getResultSet();
- }
-
return wrapResult(rs, wrap);
}
@@ -240,8 +219,9 @@
return _conn;
}
- // JDBC 3.0 (unsupported) method follow; these are required to be able
+ // JDBC 3.0 (unsupported) method follow; these are required to be able
// to compile against JDK 1.4
+
public boolean getMoreResults(int i) throws SQLException {
throw new UnsupportedOperationException();
}
@@ -278,3 +258,4 @@
throw new UnsupportedOperationException();
}
}
+
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEvent.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEvent.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEvent.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEvent.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ * 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
@@ -16,80 +13,79 @@
package org.apache.openjpa.lib.jdbc;
import java.sql.*;
-
import java.util.*;
-
/**
- * <p>A JDBC event. The event source will be the connection.</p>
- *
- * @see JDBCListener
- * @author Marc Prud'hommeaux
- * @author Abe White
+ * A JDBC event. The event source will be the connection.
+ *
+ * @see JDBCListener
+ * @author Marc Prud'hommeaux
+ * @author Abe White
*/
public class JDBCEvent extends EventObject {
/**
- * Type code indicating that a {@link Statement} is being prepared.
+ * Type code indicating that a {@link Statement} is being prepared.
*/
public static final short BEFORE_PREPARE_STATEMENT = 1;
/**
- * Type code indicating that a {@link Statement} is being prepared.
+ * Type code indicating that a {@link Statement} is being prepared.
*/
public static final short AFTER_PREPARE_STATEMENT = 2;
/**
- * Type code indicating that a {@link Statement} is being created.
+ * Type code indicating that a {@link Statement} is being created.
*/
public static final short BEFORE_CREATE_STATEMENT = 3;
/**
- * Type code indicating that a {@link Statement} is being created.
+ * Type code indicating that a {@link Statement} is being created.
*/
public static final short AFTER_CREATE_STATEMENT = 4;
/**
- * Type code indicating that a {@link Statement} is about to be executed.
+ * Type code indicating that a {@link Statement} is about to be executed.
*/
public static final short BEFORE_EXECUTE_STATEMENT = 5;
/**
- * Type code indicating that a {@link Statement} completed execution.
+ * Type code indicating that a {@link Statement} completed execution.
*/
public static final short AFTER_EXECUTE_STATEMENT = 6;
/**
- * Type code indicating that a {@link Connection} is about to be committed.
+ * Type code indicating that a {@link Connection} is about to be committed.
*/
public static final short BEFORE_COMMIT = 7;
/**
- * Type code indicating that a {@link Connection} was just committed.
+ * Type code indicating that a {@link Connection} was just committed.
*/
public static final short AFTER_COMMIT = 8;
/**
- * Type code indicating that a rollback is about to occur.
+ * Type code indicating that a rollback is about to occur.
*/
public static final short BEFORE_ROLLBACK = 9;
/**
- * Type code indicating that a rollback just occured.
+ * Type code indicating that a rollback just occured.
*/
public static final short AFTER_ROLLBACK = 10;
/**
- * Type code indicating that a connection was obtained. This does
- * not necessarily mean that the connection is new if pooling is enabled.
+ * Type code indicating that a connection was obtained. This does
+ * not necessarily mean that the connection is new if pooling is enabled.
*/
public static final short AFTER_CONNECT = 11;
/**
- * Type code indicating that a connection was closed. This does
- * not necessarily mean that the underlying database connection was
- * severed if pooling is enabled.
+ * Type code indicating that a connection was closed. This does
+ * not necessarily mean that the underlying database connection was
+ * severed if pooling is enabled.
*/
public static final short BEFORE_CLOSE = 12;
+
private final short type;
private final long time;
private final String sql;
@@ -97,7 +93,7 @@
private final transient Statement statement;
/**
- * Constructor.
+ * Constructor.
*/
public JDBCEvent(Connection source, short type, JDBCEvent associatedEvent,
Statement statement, String sql) {
@@ -110,48 +106,49 @@
}
/**
- * Return the event's type code.
+ * Return the event's type code.
*/
public final short getType() {
return type;
}
/**
- * Return the Connection for this event.
+ * Return the Connection for this event.
*/
public final Connection getConnection() {
- return (Connection) getSource();
+ return(Connection) getSource();
}
/**
- * Return the time the event was constructed.
+ * Return the time the event was constructed.
*/
public final long getTime() {
return time;
}
/**
- * Return the associated {@link JDBCEvent} for this event.
- * For AFTER_XXX events, this will typically be the JDBCEvent
- * that was created in the BEFORE_XXX stage. This may be null when
- * an association is not appropriate for the event.
+ * Return the associated {@link JDBCEvent} for this event.
+ * For AFTER_XXX events, this will typically be the JDBCEvent
+ * that was created in the BEFORE_XXX stage. This may be null when
+ * an association is not appropriate for the event.
*/
public final JDBCEvent getAssociatedEvent() {
return associatedEvent;
}
/**
- * Return the SQL associated with this event; may be null.
+ * Return the SQL associated with this event; may be null.
*/
public final String getSQL() {
return sql;
}
/**
- * Return the Statement for this event, may be null for events
- * unrelated to Statement execution.
+ * Return the Statement for this event, may be null for events
+ * unrelated to Statement execution.
*/
public final Statement getStatement() {
return statement;
}
}
+
Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java Fri Jun 30 15:37:18 2006
@@ -1,13 +1,10 @@
/*
* Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ * 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
@@ -15,119 +12,88 @@
*/
package org.apache.openjpa.lib.jdbc;
-import org.apache.openjpa.lib.util.concurrent.*;
-
import java.sql.*;
-
import java.util.*;
-
import javax.sql.*;
-
+import org.apache.openjpa.lib.util.concurrent.*;
/**
- * <p>Manages the firing of {@link JDBCEvent}s.</p>
- *
- * @author Abe White
- * @nojavadoc */
+ * Manages the firing of {@link JDBCEvent}s.
+ *
+ * @author Abe White
+ * @nojavadoc
+ */
public class JDBCEventConnectionDecorator extends AbstractConcurrentEventManager
implements ConnectionDecorator {
public Connection decorate(Connection conn) {
- if (!hasListeners()) {
+ if (!hasListeners())
return conn;
- }
-
return new EventConnection(conn);
}
/**
- * Fire the given event to all listeners. Prevents creation of an
- * event object when there are no listeners.
+ * Fire the given event to all listeners. Prevents creation of an
+ * event object when there are no listeners.
*/
private JDBCEvent fireEvent(Connection source, short type,
JDBCEvent associatedEvent, Statement stmnt, String sql) {
- if (!hasListeners()) {
+ if (!hasListeners())
return null;
- }
- JDBCEvent event = new JDBCEvent(source, type, associatedEvent, stmnt,
- sql);
+ JDBCEvent event = new JDBCEvent(source, type, associatedEvent,
+ stmnt, sql);
fireEvent(event);
-
return event;
}
/**
- * Fire the given event to all listeners.
+ * Fire the given event to all listeners.
*/
protected void fireEvent(Object event, Object listener) {
JDBCListener listen = (JDBCListener) listener;
JDBCEvent ev = (JDBCEvent) event;
-
switch (ev.getType()) {
case JDBCEvent.BEFORE_PREPARE_STATEMENT:
listen.beforePrepareStatement(ev);
-
break;
-
case JDBCEvent.AFTER_PREPARE_STATEMENT:
listen.afterPrepareStatement(ev);
-
break;
-
case JDBCEvent.BEFORE_CREATE_STATEMENT:
listen.beforeCreateStatement(ev);
-
break;
-
case JDBCEvent.AFTER_CREATE_STATEMENT:
listen.afterCreateStatement(ev);
-
break;
-
case JDBCEvent.BEFORE_EXECUTE_STATEMENT:
listen.beforeExecuteStatement(ev);
-
break;
-
case JDBCEvent.AFTER_EXECUTE_STATEMENT:
listen.afterExecuteStatement(ev);
-
break;
-
case JDBCEvent.BEFORE_COMMIT:
listen.beforeCommit(ev);
-
break;
-
case JDBCEvent.AFTER_COMMIT:
listen.afterCommit(ev);
-
break;
-
case JDBCEvent.BEFORE_ROLLBACK:
listen.beforeRollback(ev);
-
break;
-
case JDBCEvent.AFTER_ROLLBACK:
listen.afterRollback(ev);
-
break;
-
case JDBCEvent.AFTER_CONNECT:
listen.afterConnect(ev);
-
break;
-
case JDBCEvent.BEFORE_CLOSE:
listen.beforeClose(ev);
-
break;
}
}
/**
- * Fires events as appropriate.
+ * Fires events as appropriate.
*/
private class EventConnection extends DelegatingConnection {
public EventConnection(Connection conn) {
@@ -137,108 +103,104 @@
public void commit() throws SQLException {
JDBCEvent before = fireEvent(getDelegate(),
- JDBCEvent.BEFORE_COMMIT, null, null, null);
-
+ JDBCEvent.BEFORE_COMMIT, null, null, null);
try {
super.commit();
- } finally {
- fireEvent(getDelegate(), JDBCEvent.AFTER_COMMIT, before, null,
- null);
+ }
+ finally {
+ fireEvent(getDelegate(), JDBCEvent.AFTER_COMMIT, before,
+ null, null);
}
}
public void rollback() throws SQLException {
JDBCEvent before = fireEvent(getDelegate(),
- JDBCEvent.BEFORE_ROLLBACK, null, null, null);
-
+ JDBCEvent.BEFORE_ROLLBACK, null, null, null);
try {
super.rollback();
- } finally {
+ }
+ finally {
fireEvent(getDelegate(), JDBCEvent.AFTER_ROLLBACK, before,
null, null);
}
}
- protected Statement createStatement(boolean wrap)
- throws SQLException {
+ protected Statement createStatement(boolean wrap) throws SQLException {
JDBCEvent before = fireEvent(getDelegate(),
- JDBCEvent.BEFORE_CREATE_STATEMENT, null, null, null);
+ JDBCEvent.BEFORE_CREATE_STATEMENT, null, null, null);
Statement stmnt = null;
-
try {
stmnt = new EventStatement(super.createStatement(false),
- EventConnection.this);
- } finally {
+ EventConnection.this);
+ }
+ finally {
fireEvent(getDelegate(), JDBCEvent.AFTER_CREATE_STATEMENT,
before, stmnt, null);
}
-
return stmnt;
}
protected Statement createStatement(int rsType, int rsConcur,
boolean wrap) throws SQLException {
JDBCEvent before = fireEvent(getDelegate(),
- JDBCEvent.BEFORE_CREATE_STATEMENT, null, null, null);
+ JDBCEvent.BEFORE_CREATE_STATEMENT, null, null, null);
Statement stmnt = null;
-
try {
- stmnt = new EventStatement(super.createStatement(rsType,
- rsConcur, false), EventConnection.this);
- } finally {
+ stmnt = new EventStatement(super.createStatement
+ (rsType, rsConcur, false), EventConnection.this);
+ }
+ finally {
fireEvent(getDelegate(), JDBCEvent.AFTER_CREATE_STATEMENT,
before, stmnt, null);
}
-
return stmnt;
}
protected PreparedStatement prepareStatement(String sql, boolean wrap)
throws SQLException {
JDBCEvent before = fireEvent(getDelegate(),
- JDBCEvent.BEFORE_PREPARE_STATEMENT, null, null, sql);
+ JDBCEvent.BEFORE_PREPARE_STATEMENT, null, null, sql);
PreparedStatement stmnt = null;
-
try {
- stmnt = new EventPreparedStatement(super.prepareStatement(sql,
- false), EventConnection.this, sql);
- } finally {
+ stmnt = new EventPreparedStatement(super.prepareStatement
+ (sql, false), EventConnection.this, sql);
+ }
+ finally {
fireEvent(getDelegate(), JDBCEvent.AFTER_PREPARE_STATEMENT,
before, stmnt, sql);
}
-
return stmnt;
}
protected PreparedStatement prepareStatement(String sql, int rsType,
int rsConcur, boolean wrap) throws SQLException {
JDBCEvent before = fireEvent(getDelegate(),
- JDBCEvent.BEFORE_PREPARE_STATEMENT, null, null, sql);
+ JDBCEvent.BEFORE_PREPARE_STATEMENT, null, null, sql);
PreparedStatement stmnt = null;
-
try {
- stmnt = new EventPreparedStatement(super.prepareStatement(sql,
- rsType, rsConcur, false), EventConnection.this, sql);
- } finally {
+ stmnt = new EventPreparedStatement(super.prepareStatement
+ (sql, rsType, rsConcur, false), EventConnection.this, sql);
+ }
+ finally {
fireEvent(getDelegate(), JDBCEvent.AFTER_PREPARE_STATEMENT,
before, stmnt, sql);
}
-
return stmnt;
}
public void close() throws SQLException {
try {
- fireEvent(getDelegate(), JDBCEvent.BEFORE_CLOSE, null, null,
- null);
- } finally {
+ fireEvent(getDelegate(), JDBCEvent.BEFORE_CLOSE,
+ null, null, null);
+ }
+ finally {
super.close();
}
}
}
/**
- * Fires events as appropriate.
+ * Fires events as appropriate.
*/
private class EventPreparedStatement extends DelegatingPreparedStatement {
private final EventConnection _conn;
@@ -253,50 +215,46 @@
public int executeUpdate() throws SQLException {
JDBCEvent before = fireEvent(_conn.getDelegate(),
- JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(),
- _sql);
-
+ JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), _sql);
try {
return super.executeUpdate();
- } finally {
+ }
+ finally {
fireEvent(_conn.getDelegate(),
- JDBCEvent.AFTER_EXECUTE_STATEMENT, before, getDelegate(),
- _sql);
+ JDBCEvent.AFTER_EXECUTE_STATEMENT, before,
+ getDelegate(), _sql);
}
}
- protected ResultSet executeQuery(boolean wrap)
- throws SQLException {
+ protected ResultSet executeQuery(boolean wrap) throws SQLException {
JDBCEvent before = fireEvent(_conn.getDelegate(),
- JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(),
- _sql);
-
+ JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), _sql);
try {
return super.executeQuery(wrap);
- } finally {
+ }
+ finally {
fireEvent(_conn.getDelegate(),
- JDBCEvent.AFTER_EXECUTE_STATEMENT, before, getDelegate(),
- _sql);
+ JDBCEvent.AFTER_EXECUTE_STATEMENT, before,
+ getDelegate(), _sql);
}
}
public int[] executeBatch() throws SQLException {
JDBCEvent before = fireEvent(_conn.getDelegate(),
- JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(),
- _sql);
-
+ JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), _sql);
try {
return super.executeBatch();
- } finally {
+ }
+ finally {
fireEvent(_conn.getDelegate(),
- JDBCEvent.AFTER_EXECUTE_STATEMENT, before, getDelegate(),
- _sql);
+ JDBCEvent.AFTER_EXECUTE_STATEMENT, before,
+ getDelegate(), _sql);
}
}
}
/**
- * Fires events as appropriate.
+ * Fires events as appropriate.
*/
private class EventStatement extends DelegatingStatement {
private final EventConnection _conn;
@@ -308,28 +266,28 @@
public int executeUpdate(String sql) throws SQLException {
JDBCEvent before = fireEvent(_conn.getDelegate(),
- JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql);
-
+ JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql);
try {
return super.executeUpdate(sql);
- } finally {
+ }
+ finally {
fireEvent(_conn.getDelegate(),
- JDBCEvent.AFTER_EXECUTE_STATEMENT, before, getDelegate(),
- sql);
+ JDBCEvent.AFTER_EXECUTE_STATEMENT, before,
+ getDelegate(), sql);
}
}
protected ResultSet executeQuery(String sql, boolean wrap)
throws SQLException {
JDBCEvent before = fireEvent(_conn.getDelegate(),
- JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql);
-
+ JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql);
try {
return super.executeQuery(sql, wrap);
- } finally {
+ }
+ finally {
fireEvent(_conn.getDelegate(),
- JDBCEvent.AFTER_EXECUTE_STATEMENT, before, getDelegate(),
- sql);
+ JDBCEvent.AFTER_EXECUTE_STATEMENT, before,
+ getDelegate(), sql);
}
}
}