You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2013/06/18 10:51:43 UTC
svn commit: r1494071 - in /db/derby/code/trunk/java:
engine/org/apache/derby/iapi/jdbc/ engine/org/apache/derby/impl/jdbc/
engine/org/apache/derby/jdbc/
testing/org/apache/derbyTesting/functionTests/tests/jdbc4/
Author: kahatlen
Date: Tue Jun 18 08:51:42 2013
New Revision: 1494071
URL: http://svn.apache.org/r1494071
Log:
DERBY-1984: Re-factor JDBC classes to remove support for JDBC 2
Collapse BrokeredStatement, BrokeredConnection, EngineConnection and
EmbedConnection class hierarchies.
Removed:
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement40.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement40.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement40.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineConnection40.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection40.java
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement42.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection42.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement42.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Conn.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/XA40Test.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement.java?rev=1494071&r1=1494070&r2=1494071&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement.java Tue Jun 18 08:51:42 2013
@@ -21,6 +21,8 @@
package org.apache.derby.iapi.jdbc;
+import java.io.InputStream;
+import java.io.Reader;
import java.sql.*;
import java.math.BigDecimal;
@@ -29,9 +31,10 @@ import java.util.Map;
/**
- * JDBC 3 brokered CallableStatement
+ * Brokered CallableStatement.
+ * This class implements the JDBC 4.1 interface.
*/
-public abstract class BrokeredCallableStatement extends BrokeredPreparedStatement
+public class BrokeredCallableStatement extends BrokeredPreparedStatement
implements CallableStatement
{
@@ -428,6 +431,185 @@ public abstract class BrokeredCallableSt
getCallableStatement().registerOutParameter(a, b, c);
}
+ // JDBC 4.0 methods
+
+ public final Reader getCharacterStream(int parameterIndex)
+ throws SQLException {
+ return getCallableStatement().getCharacterStream(parameterIndex);
+ }
+
+ public final Reader getCharacterStream(String parameterName)
+ throws SQLException {
+ return getCallableStatement().getCharacterStream(parameterName);
+ }
+
+ public final Reader getNCharacterStream(int parameterIndex)
+ throws SQLException {
+ return getCallableStatement().getNCharacterStream(parameterIndex);
+ }
+
+ public final Reader getNCharacterStream(String parameterName)
+ throws SQLException {
+ return getCallableStatement().getNCharacterStream(parameterName);
+ }
+
+ public final String getNString(int parameterIndex)
+ throws SQLException {
+ return getCallableStatement().getNString(parameterIndex);
+ }
+
+ public final String getNString(String parameterName)
+ throws SQLException {
+ return getCallableStatement().getNString(parameterName);
+ }
+
+ public final RowId getRowId(int parameterIndex) throws SQLException {
+ return getCallableStatement().getRowId(parameterIndex);
+ }
+
+ public final RowId getRowId(String parameterName) throws SQLException {
+ return getCallableStatement().getRowId(parameterName);
+ }
+
+ public final void setRowId(String parameterName, RowId x)
+ throws SQLException {
+ getCallableStatement().setRowId(parameterName, x);
+ }
+
+ public final void setBlob(String parameterName, Blob x)
+ throws SQLException {
+ getCallableStatement().setBlob(parameterName, x);
+ }
+
+ public final void setClob(String parameterName, Clob x)
+ throws SQLException {
+ getCallableStatement().setClob(parameterName, x);
+ }
+
+ public final void setNString(String parameterName, String value)
+ throws SQLException {
+ getCallableStatement().setNString(parameterName, value);
+ }
+
+ public final void setNCharacterStream(String parameterName, Reader value)
+ throws SQLException {
+ getCallableStatement().setNCharacterStream(parameterName, value);
+ }
+
+ public final void setNCharacterStream(String parameterName, Reader value,
+ long length)
+ throws SQLException {
+ getCallableStatement().setNCharacterStream(
+ parameterName, value, length);
+ }
+
+ public final void setNClob(String parameterName, NClob value)
+ throws SQLException {
+ getCallableStatement().setNClob(parameterName, value);
+ }
+
+ public final void setClob(String parameterName, Reader reader)
+ throws SQLException {
+ getCallableStatement().setClob(parameterName, reader);
+ }
+
+ public final void setClob(String parameterName, Reader reader, long length)
+ throws SQLException {
+ getCallableStatement().setClob(parameterName, reader, length);
+ }
+
+ public final void setBlob(String parameterName, InputStream inputStream)
+ throws SQLException {
+ getCallableStatement().setBlob(parameterName, inputStream);
+ }
+
+ public final void setBlob(String parameterName, InputStream inputStream,
+ long length)
+ throws SQLException {
+ getCallableStatement().setBlob(parameterName, inputStream, length);
+ }
+
+ public final void setNClob(String parameterName, Reader reader)
+ throws SQLException {
+ getCallableStatement().setNClob(parameterName, reader);
+ }
+
+ public final void setNClob(String parameterName, Reader reader, long length)
+ throws SQLException {
+ getCallableStatement().setNClob(parameterName, reader, length);
+ }
+
+ public NClob getNClob(int i) throws SQLException {
+ return getCallableStatement().getNClob(i);
+ }
+
+ public NClob getNClob(String parameterName) throws SQLException {
+ return getCallableStatement().getNClob(parameterName);
+ }
+
+ public final void setSQLXML(String parameterName, SQLXML xmlObject)
+ throws SQLException {
+ getCallableStatement().setSQLXML(parameterName, xmlObject);
+ }
+
+ public SQLXML getSQLXML(int parameterIndex) throws SQLException {
+ return getCallableStatement().getSQLXML(parameterIndex);
+ }
+
+ public SQLXML getSQLXML(String parametername) throws SQLException {
+ return getCallableStatement().getSQLXML(parametername);
+ }
+
+ public final void setAsciiStream(String parameterName, InputStream x)
+ throws SQLException {
+ getCallableStatement().setAsciiStream(parameterName, x);
+ }
+
+ public final void setAsciiStream(String parameterName, InputStream x,
+ long length)
+ throws SQLException {
+ getCallableStatement().setAsciiStream(parameterName, x, length);
+ }
+
+ public final void setBinaryStream(String parameterName, InputStream x)
+ throws SQLException {
+ getCallableStatement().setBinaryStream(parameterName, x);
+ }
+
+ public final void setBinaryStream(String parameterName, InputStream x,
+ long length)
+ throws SQLException {
+ getCallableStatement().setBinaryStream(parameterName, x, length);
+ }
+
+ public final void setCharacterStream(String parameterName, Reader x)
+ throws SQLException {
+ getCallableStatement().setCharacterStream(parameterName, x);
+ }
+
+ public final void setCharacterStream(String parameterName, Reader x,
+ long length)
+ throws SQLException {
+ getCallableStatement().setCharacterStream(parameterName, x, length);
+ }
+
+ ////////////////////////////////////////////////////////////////////
+ //
+ // INTRODUCED BY JDBC 4.1 IN JAVA 7
+ //
+ ////////////////////////////////////////////////////////////////////
+ public final <T> T getObject(int parameterIndex, Class<T> type)
+ throws SQLException {
+ return ((EngineCallableStatement) getCallableStatement())
+ .getObject(parameterIndex, type);
+ }
+
+ public final <T> T getObject(String parameterName, Class<T> type)
+ throws SQLException {
+ return ((EngineCallableStatement) getCallableStatement())
+ .getObject(parameterName, type);
+ }
+
/*
** Control methods
*/
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement42.java?rev=1494071&r1=1494070&r2=1494071&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement42.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement42.java Tue Jun 18 08:51:42 2013
@@ -24,7 +24,7 @@ package org.apache.derby.iapi.jdbc;
import java.sql.SQLException;
import java.sql.SQLType;
-public class BrokeredCallableStatement42 extends BrokeredCallableStatement40
+public class BrokeredCallableStatement42 extends BrokeredCallableStatement
{
public BrokeredCallableStatement42( BrokeredStatementControl control, String sql )
throws SQLException
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java?rev=1494071&r1=1494070&r2=1494071&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java Tue Jun 18 08:51:42 2013
@@ -21,15 +21,24 @@
package org.apache.derby.iapi.jdbc;
+import java.sql.Array;
+import java.sql.Blob;
import java.sql.CallableStatement;
+import java.sql.Clob;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
+import java.sql.NClob;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
+import java.sql.SQLClientInfoException;
import java.sql.SQLException;
import java.sql.SQLWarning;
+import java.sql.SQLXML;
import java.sql.Savepoint;
import java.sql.Statement;
+import java.sql.Struct;
+import java.util.Properties;
+import java.util.concurrent.Executor;
import org.apache.derby.iapi.error.SQLWarningFactory;
import org.apache.derby.shared.common.reference.SQLState;
@@ -37,7 +46,7 @@ import org.apache.derby.shared.common.re
* This is a rudimentary connection that delegates
* EVERYTHING to Connection.
*/
-public abstract class BrokeredConnection implements EngineConnection
+public class BrokeredConnection implements EngineConnection
{
// default for Derby
@@ -570,15 +579,37 @@ public abstract class BrokeredConnection
}
}
- public abstract BrokeredStatement newBrokeredStatement(BrokeredStatementControl statementControl) throws SQLException;
+ public final BrokeredStatement newBrokeredStatement(
+ BrokeredStatementControl statementControl) throws SQLException {
+ try {
+ return new BrokeredStatement(statementControl);
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
- public abstract BrokeredPreparedStatement newBrokeredStatement(
- BrokeredStatementControl statementControl, String sql,
- Object generatedKeys) throws SQLException;
+ public BrokeredPreparedStatement newBrokeredStatement(
+ BrokeredStatementControl statementControl,
+ String sql, Object generatedKeys) throws SQLException {
+ try {
+ return new BrokeredPreparedStatement(statementControl, sql, generatedKeys);
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
- public abstract BrokeredCallableStatement newBrokeredStatement(
+ public BrokeredCallableStatement newBrokeredStatement(
BrokeredStatementControl statementControl, String sql)
- throws SQLException;
+ throws SQLException {
+ try {
+ return new BrokeredCallableStatement(statementControl, sql);
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
/**
* set the DrdaId for this connection. The drdaID prints with the
@@ -665,7 +696,7 @@ public abstract class BrokeredConnection
}
/*
- * JDBC 3.0 methods that are exposed through EngineConnection.
+ * JDBC 3.0 methods.
*/
/**
@@ -702,7 +733,253 @@ public abstract class BrokeredConnection
throw se;
}
}
-
+
+ // JDBC 4.0 methods
+
+ public final Array createArrayOf(String typeName, Object[] elements)
+ throws SQLException {
+ try {
+ return getRealConnection().createArrayOf(typeName, elements);
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+ /**
+ *
+ * Constructs an object that implements the {@code Blob} interface. The
+ * object returned initially contains no data. The {@code setBinaryStream}
+ * and {@code setBytes} methods of the {@code Blob} interface may be used to
+ * add data to the {@code Blob}.
+ *
+ * @return An object that implements the {@code Blob} interface
+ * @throws SQLException if an object that implements the {@code Blob}
+ * interface can not be constructed, this method is called on a closed
+ * connection or a database access error occurs.
+ *
+ */
+ public final Blob createBlob() throws SQLException {
+ // Forward the createBlob call to the physical connection
+ try {
+ return getRealConnection().createBlob();
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+ /**
+ *
+ * Constructs an object that implements the {@code Clob} interface. The
+ * object returned initially contains no data. The {@code setAsciiStream},
+ * {@code setCharacterStream} and {@code setString} methods of the
+ * {@code Clob} interface may be used to add data to the {@code Clob}.
+ *
+ * @return An object that implements the {@code Clob} interface
+ * @throws SQLException if an object that implements the {@code Clob}
+ * interface can not be constructed, this method is called on a closed
+ * connection or a database access error occurs.
+ *
+ */
+ public final Clob createClob() throws SQLException {
+ // Forward the createClob call to the physical connection
+ try {
+ return getRealConnection().createClob();
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+ public final NClob createNClob() throws SQLException {
+ try {
+ return getRealConnection().createNClob();
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+ public final SQLXML createSQLXML() throws SQLException {
+ try {
+ return getRealConnection().createSQLXML();
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+ public final Struct createStruct(String typeName, Object[] attributes)
+ throws SQLException {
+ try {
+ return getRealConnection().createStruct(typeName, attributes);
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+ /**
+ * Checks if the connection has not been closed and is still valid. The
+ * validity is checked by running a simple query against the database.
+ *
+ * @param timeout The time in seconds to wait for the database operation
+ * used to validate the connection to complete. If the timeout period
+ * expires before the operation completes, this method returns false. A
+ * value of 0 indicates a timeout is not applied to the database operation.
+ * @return true if the connection is valid, false otherwise
+ * @throws SQLException if the call on the physical connection throws an
+ * exception.
+ */
+ public final boolean isValid(int timeout) throws SQLException {
+ // Check first if the Brokered connection is closed
+ if (isClosed()) {
+ return false;
+ }
+
+ // Forward the isValid call to the physical connection
+ try {
+ return getRealConnection().isValid(timeout);
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+ /**
+ * {@code setClientInfo} forwards to the real connection.
+ *
+ * @param name the property key {@code String}
+ * @param value the property value {@code String}
+ * @exception SQLClientInfoException if the property is not supported or the
+ * real connection could not be obtained.
+ */
+ public final void setClientInfo(String name, String value)
+ throws SQLClientInfoException {
+ try {
+ getRealConnection().setClientInfo(name, value);
+ } catch (SQLClientInfoException se) {
+ notifyException(se);
+ throw se;
+ } catch (SQLException se) {
+ notifyException(se);
+ throw new SQLClientInfoException(se.getMessage(), se.getSQLState(),
+ se.getErrorCode(),
+ new FailedProperties40(
+ FailedProperties40.makeProperties(name, value))
+ .getProperties());
+ }
+ }
+
+ /**
+ * {@code setClientInfo} forwards to the real connection. If the call to
+ * {@code getRealConnection} fails the resulting {@code SQLException} is
+ * wrapped in a {@code SQLClientInfoException} to satisfy the specified
+ * signature.
+ *
+ * @param properties a {@code Properties} object with the properties to set.
+ * @exception SQLClientInfoException if the properties are not supported or
+ * the real connection could not be obtained.
+ */
+ public final void setClientInfo(Properties properties)
+ throws SQLClientInfoException {
+ try {
+ getRealConnection().setClientInfo(properties);
+ } catch (SQLClientInfoException cie) {
+ notifyException(cie);
+ throw cie;
+ } catch (SQLException se) {
+ notifyException(se);
+ throw new SQLClientInfoException(se.getMessage(), se.getSQLState(),
+ se.getErrorCode(),
+ (new FailedProperties40(properties)).getProperties());
+ }
+ }
+
+ /**
+ * {@code getClientInfo} forwards to the real connection.
+ *
+ * @param name a {@code String} that is the property key to get.
+ * @return a {@code String} that is returned from the real connection.
+ * @exception SQLException if a database access error occurs.
+ */
+ public final String getClientInfo(String name)
+ throws SQLException {
+ try {
+ return getRealConnection().getClientInfo(name);
+ } catch (SQLException se) {
+ notifyException(se);
+ throw se;
+ }
+ }
+
+ /**
+ * {@code getClientInfo} forwards to the real connection.
+ *
+ * @return a {@code Properties} object from the real connection.
+ * @exception SQLException if a database access error occurs.
+ */
+ public final Properties getClientInfo()
+ throws SQLException {
+ try {
+ return getRealConnection().getClientInfo();
+ } catch (SQLException se) {
+ notifyException(se);
+ throw se;
+ }
+ }
+
+ /**
+ * Returns false unless {@code iface} is implemented.
+ *
+ * @param iface a Class defining an interface.
+ * @return true if this implements the interface or directly or indirectly
+ * wraps an object that does.
+ * @throws SQLException if an error occurs while determining
+ * whether this is a wrapper for an object with the given interface.
+ */
+ public final boolean isWrapperFor(Class<?> iface) throws SQLException {
+ try {
+ if (getRealConnection().isClosed()) {
+ throw noCurrentConnection();
+ }
+ return iface.isInstance(this);
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+ /**
+ * Returns {@code this} if this class implements the interface.
+ *
+ * @param iface a Class defining an interface
+ * @return an object that implements the interface
+ * @throws SQLException if no object if found that implements the
+ * interface
+ */
+ public final <T> T unwrap(Class<T> iface)
+ throws SQLException {
+ try {
+ if (getRealConnection().isClosed()) {
+ throw noCurrentConnection();
+ }
+ // Derby does not implement non-standard methods on
+ // JDBC objects.
+ try {
+ return iface.cast(this);
+ } catch (ClassCastException cce) {
+ throw ExceptionFactory.getInstance().getSQLException(
+ SQLState.UNABLE_TO_UNWRAP,
+ (SQLException) null, (Throwable) null, iface);
+ }
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
/*
** Methods private to the class.
*/
@@ -804,4 +1081,30 @@ public abstract class BrokeredConnection
}
}
+ public void abort(Executor executor) throws SQLException {
+ if (!isClosed) {
+ ((EngineConnection) getRealConnection()).abort(executor);
+ }
+ }
+
+ public int getNetworkTimeout() throws SQLException {
+ try {
+ return ((EngineConnection) getRealConnection()).getNetworkTimeout();
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+ public void setNetworkTimeout(Executor executor, int milliseconds)
+ throws SQLException {
+ try {
+ ((EngineConnection) getRealConnection())
+ .setNetworkTimeout(executor, milliseconds);
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection42.java?rev=1494071&r1=1494070&r2=1494071&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection42.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection42.java Tue Jun 18 08:51:42 2013
@@ -23,8 +23,7 @@ package org.apache.derby.iapi.jdbc;
import java.sql.SQLException;
-public class BrokeredConnection42
- extends BrokeredConnection40
+public class BrokeredConnection42 extends BrokeredConnection
{
/** Creates a new instance of BrokeredConnection40 */
public BrokeredConnection42(BrokeredConnectionControl control)
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java?rev=1494071&r1=1494070&r2=1494071&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java Tue Jun 18 08:51:42 2013
@@ -28,10 +28,12 @@ import java.sql.*;
import java.util.Calendar;
/**
- JDBC 3 brokered PreparedStatement. Forwards calls off to a real prepared statement
- obtained through the BrokeredStatementControl getRealPreparedStatement method.
+ * A brokered {@code PreparedStatement} that forwards calls off to a real
+ * {@code PreparedStatement} obtained through the
+ * {@link BrokeredStatementControl#getRealPreparedStatement} method.
+ * This class implements the JDBC 4.1 interface.
*/
-public abstract class BrokeredPreparedStatement extends BrokeredStatement
+public class BrokeredPreparedStatement extends BrokeredStatement
implements EnginePreparedStatement
{
@@ -536,6 +538,151 @@ public abstract class BrokeredPreparedSt
return getPreparedStatement().getParameterMetaData();
}
+ // JDBC 4.0 methods
+
+ public final void setRowId(int parameterIndex, RowId x)
+ throws SQLException {
+ getPreparedStatement().setRowId(parameterIndex, x);
+ }
+
+ public final void setNString(int index, String value) throws SQLException {
+ getPreparedStatement().setNString(index, value);
+ }
+
+ public final void setNCharacterStream(int parameterIndex, Reader value)
+ throws SQLException {
+ getPreparedStatement().setNCharacterStream(parameterIndex, value);
+ }
+
+ public final void setNCharacterStream(int index, Reader value, long length)
+ throws SQLException {
+ getPreparedStatement().setNCharacterStream(index, value, length);
+ }
+
+ public final void setNClob(int index, NClob value) throws SQLException {
+ getPreparedStatement().setNClob(index, value);
+ }
+
+ public final void setClob(int parameterIndex, Reader reader, long length)
+ throws SQLException {
+ getPreparedStatement().setClob(parameterIndex, reader, length);
+ }
+
+ public final void setBlob(int parameterIndex, InputStream inputStream,
+ long length)
+ throws SQLException {
+ getPreparedStatement().setBlob(parameterIndex, inputStream, length);
+ }
+
+ public final void setNClob(int parameterIndex, Reader reader)
+ throws SQLException {
+ getPreparedStatement().setNClob(parameterIndex, reader);
+ }
+
+ public final void setNClob(int parameterIndex, Reader reader, long length)
+ throws SQLException {
+ getPreparedStatement().setNClob(parameterIndex, reader, length);
+ }
+
+ public final void setSQLXML(int parameterIndex, SQLXML xmlObject)
+ throws SQLException {
+ getPreparedStatement().setSQLXML(parameterIndex, xmlObject);
+ }
+
+ /**
+ * Sets the designated parameter to the given input stream.
+ *
+ * @param parameterIndex the first parameter is 1, the second is 2, ...
+ * @param x the Java input stream that contains the ASCII parameter value
+ * @throws SQLException if a database access error occurs or this method is
+ * called on a closed {@code PreparedStatement}
+ */
+ public final void setAsciiStream(int parameterIndex, InputStream x)
+ throws SQLException {
+ getPreparedStatement().setAsciiStream(parameterIndex, x);
+ }
+
+ /**
+ * Sets the designated parameter to the given input stream, which will have
+ * the specified number of bytes.
+ *
+ * @param parameterIndex the first parameter is 1, the second is 2, ...
+ * @param x the java input stream which contains the ASCII parameter value
+ * @param length the number of bytes in the stream
+ * @exception SQLException thrown on failure.
+ *
+ */
+ public final void setAsciiStream(int parameterIndex, InputStream x,
+ long length)
+ throws SQLException {
+ getPreparedStatement().setAsciiStream(parameterIndex, x, length);
+ }
+
+ /**
+ * Sets the designated parameter to the given input stream, which will have
+ * the specified number of bytes.
+ *
+ * @param parameterIndex the first parameter is 1, the second is 2, ...
+ * @param x the java input stream which contains the binary parameter value
+ * @param length the number of bytes in the stream
+ * @exception SQLException thrown on failure.
+ *
+ */
+ public final void setBinaryStream(int parameterIndex, InputStream x,
+ long length)
+ throws SQLException {
+ getPreparedStatement().setBinaryStream(parameterIndex, x, length);
+ }
+
+ /**
+ * Sets the designated parameter to a {@code InputStream} object. This
+ * method differs from the {@code setBinaryStream(int, InputStream)} method
+ * because it informs the driver that the parameter value should be sent to
+ * the server as a {@code BLOB}.
+ *
+ * @param inputStream an object that contains the data to set the parameter
+ * value to.
+ * @throws SQLException if a database access error occurs, this method is
+ * called on a closed {@code PreparedStatement}
+ */
+ public final void setBlob(int parameterIndex, InputStream inputStream)
+ throws SQLException {
+ getPreparedStatement().setBlob(parameterIndex, inputStream);
+ }
+
+ /**
+ * Sets the designated parameter to the given Reader, which will have the
+ * specified number of bytes.
+ *
+ * @param parameterIndex the first parameter is 1, the second is 2, ...
+ * @param x the java Reader which contains the UNICODE value
+ * @param length the number of bytes in the stream
+ * @exception SQLException thrown on failure.
+ *
+ */
+ public final void setCharacterStream(int parameterIndex, Reader x,
+ long length)
+ throws SQLException {
+ getPreparedStatement().setCharacterStream(parameterIndex, x, length);
+ }
+
+ /**
+ * Sets the designated parameter to a {@code Reader} object. This method
+ * differs from the {@code setCharacterStream(int,Reader)} method because
+ * it informs the driver that the parameter value should be sent to the
+ * server as a {@code CLOB}.
+ *
+ * @param parameterIndex the first parameter is 1, the second is 2, ...
+ * @param reader an object that contains the data to set the parameter value
+ * to.
+ * @throws SQLException if a database access error occurs, this method is
+ * called on a closed PreparedStatement
+ */
+ public final void setClob(int parameterIndex, Reader reader)
+ throws SQLException {
+ getPreparedStatement().setClob(parameterIndex, reader);
+ }
+
/*
** Control methods.
*/
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement42.java?rev=1494071&r1=1494070&r2=1494071&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement42.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement42.java Tue Jun 18 08:51:42 2013
@@ -24,7 +24,7 @@ package org.apache.derby.iapi.jdbc;
import java.sql.SQLException;
import java.sql.SQLType;
-public class BrokeredPreparedStatement42 extends BrokeredPreparedStatement40
+public class BrokeredPreparedStatement42 extends BrokeredPreparedStatement
{
public BrokeredPreparedStatement42
(BrokeredStatementControl control, String sql, Object generatedKeys) throws SQLException
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java?rev=1494071&r1=1494070&r2=1494071&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java Tue Jun 18 08:51:42 2013
@@ -31,8 +31,9 @@ import java.sql.Statement;
/**
A Statement implementation that forwards all of its requests to an underlying Statement.
+ This class implements the JDBC 4.1 interface.
*/
-public abstract class BrokeredStatement implements EngineStatement
+public class BrokeredStatement implements EngineStatement
{
/**
@@ -600,7 +601,27 @@ public abstract class BrokeredStatement
SQLState.UNABLE_TO_UNWRAP, null, null,
new Object[]{ iface });
}
-
+
+ /**
+ * Forwards to the real Statement.
+ *
+ * @return true if the underlying Statement is poolable, false otherwise.
+ * @throws SQLException if the forwarding call fails.
+ */
+ public final boolean isPoolable() throws SQLException {
+ return getStatement().isPoolable();
+ }
+
+ /**
+ * Forwards to the real Statement.
+ *
+ * @param poolable the new value for the poolable hint.
+ * @throws SQLException if the forwarding call fails.
+ */
+ public final void setPoolable(boolean poolable) throws SQLException {
+ getStatement().setPoolable(poolable);
+ }
+
////////////////////////////////////////////////////////////////////
//
// INTRODUCED BY JDBC 4.1 IN JAVA 7
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java?rev=1494071&r1=1494070&r2=1494071&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java Tue Jun 18 08:51:42 2013
@@ -23,6 +23,7 @@ package org.apache.derby.iapi.jdbc;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLWarning;
+import java.util.concurrent.Executor;
/**
@@ -68,15 +69,6 @@ public interface EngineConnection extend
throws SQLException;
/**
- * Get the holdability of the connection.
- * Identical to JDBC 3.0 method, to allow holdabilty
- * to be supported in JDK 1.3 by the network server,
- * e.g. when the client is jdk 1.4 or above.
- * Can be removed once JDK 1.3 is no longer supported.
- */
- public int getHoldability() throws SQLException;
-
- /**
* Add a SQLWarning to this Connection object.
* @param newWarning Warning to be added, will be chained to any
* existing warnings.
@@ -124,5 +116,10 @@ public interface EngineConnection extend
* Set the default schema for the Connection.
*/
public void setSchema( String schemaName ) throws SQLException;
-
+
+ void abort(Executor executor) throws SQLException;
+
+ void setNetworkTimeout(Executor executor, int millis) throws SQLException;
+
+ int getNetworkTimeout() throws SQLException;
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java?rev=1494071&r1=1494070&r2=1494071&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java Tue Jun 18 08:51:42 2013
@@ -117,14 +117,14 @@ import org.apache.derby.impl.jdbc.authen
* the a synchronized object return by the rootConnection.
<P><B>Supports</B>
<UL>
- <LI> JDBC 3.0
+ <LI> JDBC 4.2
</UL>
*
*
* @see TransactionResourceImpl
*
*/
-public abstract class EmbedConnection implements EngineConnection
+public class EmbedConnection implements EngineConnection
{
protected static final StandardException exceptionClose = StandardException.closeException();
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java?rev=1494071&r1=1494070&r2=1494071&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java Tue Jun 18 08:51:42 2013
@@ -227,7 +227,7 @@ public class EmbedPreparedStatement exte
* </code>
*
* In the above case the PreparedStatement will actually be a
- * BrokeredPreparedStatement40 object. Hence when we call
+ * BrokeredPreparedStatement object. Hence when we call
* bcc.onStatementClose and pass the PreparedStatement that caused it
* applicationStatement will be the appropriate choice since it will
* contain the appropriate instance of PreparedStatement in each case
@@ -1756,7 +1756,7 @@ public class EmbedPreparedStatement exte
* </code>
*
* In the above case the PreparedStatement will actually be a
- * BrokeredPreparedStatement40 object. Hence when we call
+ * BrokeredPreparedStatement object. Hence when we call
* bcc.onStatementClose and pass the PreparedStatement that caused it
* applicationStatement will be the appropriate choice since it will
* contain the appropriate instance of PreparedStatement in each case
Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java?rev=1494071&r1=1494070&r2=1494071&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java Tue Jun 18 08:51:42 2013
@@ -24,11 +24,9 @@ package org.apache.derby.jdbc;
import java.sql.DatabaseMetaData;
import org.apache.derby.iapi.jdbc.BrokeredConnection;
import org.apache.derby.iapi.jdbc.BrokeredConnectionControl;
-import org.apache.derby.iapi.jdbc.BrokeredConnection40;
import org.apache.derby.iapi.sql.ResultSet;
import org.apache.derby.impl.jdbc.EmbedCallableStatement;
import org.apache.derby.impl.jdbc.EmbedConnection;
-import org.apache.derby.impl.jdbc.EmbedConnection40;
import org.apache.derby.impl.jdbc.EmbedDatabaseMetaData;
import org.apache.derby.impl.jdbc.EmbedPreparedStatement;
import org.apache.derby.impl.jdbc.EmbedResultSet;
@@ -52,13 +50,13 @@ import javax.sql.XAConnection;
public class Driver40 extends Driver30 {
public Connection getNewNestedConnection(EmbedConnection conn) {
- return new EmbedConnection40(conn);
+ return new EmbedConnection(conn);
}
protected EmbedConnection getNewEmbedConnection(String url, Properties info)
throws SQLException {
- return new EmbedConnection40(this, url, info);
+ return new EmbedConnection(this, url, info);
}
/**
@@ -123,7 +121,7 @@ public class Driver40 extends Driver30 {
public BrokeredConnection newBrokeredConnection(
BrokeredConnectionControl control) throws SQLException {
- return new BrokeredConnection40(control);
+ return new BrokeredConnection(control);
}
public EmbedResultSet newEmbedResultSet(EmbedConnection conn, ResultSet results, boolean forMetaData, org.apache.derby.impl.jdbc.EmbedStatement statement,boolean isAtomic) throws SQLException {
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41.java?rev=1494071&r1=1494070&r2=1494071&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41.java Tue Jun 18 08:51:42 2013
@@ -25,7 +25,7 @@ import java.sql.SQLException;
import org.apache.derby.client.am.ClientCallableStatement;
import org.apache.derby.client.am.ClientResultSet;
import org.apache.derby.client.am.LogicalCallableStatement;
-import org.apache.derby.iapi.jdbc.BrokeredCallableStatement40;
+import org.apache.derby.iapi.jdbc.BrokeredCallableStatement;
import org.apache.derby.impl.jdbc.EmbedCallableStatement;
import org.apache.derby.impl.jdbc.EmbedResultSet;
@@ -46,7 +46,7 @@ public class Wrapper41
private ClientResultSet _netclient;
private EmbedCallableStatement _embedCallableStatement;
private ClientCallableStatement _callableStatement;
- private BrokeredCallableStatement40 _brokeredCallableStatement;
+ private BrokeredCallableStatement _brokeredCallableStatement;
private LogicalCallableStatement _logicalCallableStatement;
///////////////////////////////////////////////////////////////////////
@@ -59,7 +59,7 @@ public class Wrapper41
{
if ( wrapped instanceof EmbedResultSet ) { _embedded = (EmbedResultSet) wrapped; }
else if ( wrapped instanceof EmbedCallableStatement ) { _embedCallableStatement = (EmbedCallableStatement) wrapped; }
- else if ( wrapped instanceof BrokeredCallableStatement40 ) { _brokeredCallableStatement = (BrokeredCallableStatement40) wrapped; }
+ else if ( wrapped instanceof BrokeredCallableStatement ) { _brokeredCallableStatement = (BrokeredCallableStatement) wrapped; }
else if ( wrapped instanceof ClientResultSet ) { _netclient = (ClientResultSet) wrapped; }
else if ( wrapped instanceof ClientCallableStatement ) { _callableStatement = (ClientCallableStatement) wrapped; }
else if ( wrapped instanceof LogicalCallableStatement ) { _logicalCallableStatement = (LogicalCallableStatement) wrapped; }
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Conn.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Conn.java?rev=1494071&r1=1494070&r2=1494071&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Conn.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Conn.java Tue Jun 18 08:51:42 2013
@@ -25,8 +25,8 @@ import java.sql.Connection;
import java.sql.SQLException;
import java.util.concurrent.Executor;
-import org.apache.derby.impl.jdbc.EmbedConnection40;
-import org.apache.derby.iapi.jdbc.BrokeredConnection40;
+import org.apache.derby.impl.jdbc.EmbedConnection;
+import org.apache.derby.iapi.jdbc.BrokeredConnection;
import org.apache.derby.client.am.LogicalConnection;
import org.apache.derby.client.net.NetConnection;
@@ -43,9 +43,9 @@ public class Wrapper41Conn
//
///////////////////////////////////////////////////////////////////////
- private EmbedConnection40 _embedded;
+ private EmbedConnection _embedded;
private NetConnection _netclient;
- private BrokeredConnection40 _brokeredConnection;
+ private BrokeredConnection _brokeredConnection;
private LogicalConnection _logicalConnection;
///////////////////////////////////////////////////////////////////////
@@ -56,8 +56,8 @@ public class Wrapper41Conn
public Wrapper41Conn( Object wrapped ) throws Exception
{
- if ( wrapped instanceof EmbedConnection40 ) { _embedded = (EmbedConnection40) wrapped; }
- else if ( wrapped instanceof BrokeredConnection40 ) { _brokeredConnection = (BrokeredConnection40) wrapped; }
+ if ( wrapped instanceof EmbedConnection ) { _embedded = (EmbedConnection) wrapped; }
+ else if ( wrapped instanceof BrokeredConnection ) { _brokeredConnection = (BrokeredConnection) wrapped; }
else if ( wrapped instanceof NetConnection) { _netclient = (NetConnection) wrapped; }
else if ( wrapped instanceof LogicalConnection ) { _logicalConnection = (LogicalConnection) wrapped; }
else { throw nothingWrapped(); }
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/XA40Test.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/XA40Test.java?rev=1494071&r1=1494070&r2=1494071&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/XA40Test.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/XA40Test.java Tue Jun 18 08:51:42 2013
@@ -33,9 +33,9 @@ import javax.sql.XAConnection;
import javax.sql.XADataSource;
import javax.transaction.xa.XAResource;
-import org.apache.derby.iapi.jdbc.BrokeredStatement40;
-import org.apache.derby.iapi.jdbc.BrokeredPreparedStatement40;
-import org.apache.derby.iapi.jdbc.BrokeredCallableStatement40;
+import org.apache.derby.iapi.jdbc.BrokeredStatement;
+import org.apache.derby.iapi.jdbc.BrokeredPreparedStatement;
+import org.apache.derby.iapi.jdbc.BrokeredCallableStatement;
/**
@@ -115,9 +115,9 @@ public class XA40Test extends BaseJDBCTe
public void testStatementPoolable() throws SQLException {
Statement s = con.createStatement();
if (usingEmbedded()) {
- assertTrue("s must be an instance of BrokeredStatement40, " +
+ assertTrue("s must be an instance of BrokeredStatement, " +
"but is " + s.getClass(),
- (s instanceof BrokeredStatement40));
+ (s instanceof BrokeredStatement));
}
assertFalse("Statement must not be poolable by default",
s.isPoolable());
@@ -140,9 +140,9 @@ public class XA40Test extends BaseJDBCTe
con.prepareStatement("CREATE TABLE foo(i int)");
if (usingEmbedded()) {
assertTrue("ps must be an instance of " +
- "BrokeredPreparedStatement40, " +
+ "BrokeredPreparedStatement, " +
"but is " + ps.getClass(),
- (ps instanceof BrokeredPreparedStatement40));
+ (ps instanceof BrokeredPreparedStatement));
}
assertTrue("PreparedStatement must be poolable by default",
ps.isPoolable());
@@ -165,9 +165,9 @@ public class XA40Test extends BaseJDBCTe
con.prepareCall("CALL SYSCS_UTIL.SYSCS_BACKUP_DATABASE(?)");
if (usingEmbedded()) {
assertTrue("cs must be an instance of " +
- "BrokeredCallableStatement40, " +
+ "BrokeredCallableStatement, " +
"but is " + cs.getClass(),
- (cs instanceof BrokeredCallableStatement40));
+ (cs instanceof BrokeredCallableStatement));
}
assertTrue("CallableStatement must be poolable by default",
cs.isPoolable());