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/05/14 17:40:25 UTC
svn commit: r1482405 [1/2] - in /db/derby/code/trunk: java/client/
java/client/org/apache/derby/client/ java/client/org/apache/derby/client/am/
java/client/org/apache/derby/client/net/ java/client/org/apache/derby/jdbc/
java/testing/org/apache/derbyTes...
Author: kahatlen
Date: Tue May 14 15:40:24 2013
New Revision: 1482405
URL: http://svn.apache.org/r1482405
Log:
DERBY-6213: Deprecate support for Java 5 and CDC
Build network client against Java 6 libraries.
Removed:
db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection40.java
db/derby/code/trunk/java/client/org/apache/derby/client/ClientXAConnection40.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/CachingLogicalConnection40.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientCallableStatement40.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientPreparedStatement40.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement40.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalDatabaseMetaData40.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalPreparedStatement40.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/SQLExceptionFactory40.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl40.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection40.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/NetDatabaseMetaData40.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet40.java
Modified:
db/derby/code/trunk/java/client/build.xml
db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientCallableStatement.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientCallableStatement42.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientConnection.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientDatabaseMetaData.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientPreparedStatement.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientPreparedStatement42.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientResultSet.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement42.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalDatabaseMetaData.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalPreparedStatement.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalPreparedStatement42.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/SQLExceptionFactory.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlException.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl42.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet42.java
db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java
db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver40.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/Wrapper41Driver.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoloadTest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementPoolingTest.java
db/derby/code/trunk/tools/jar/dnc.properties
Modified: db/derby/code/trunk/java/client/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/build.xml?rev=1482405&r1=1482404&r2=1482405&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/build.xml (original)
+++ db/derby/code/trunk/java/client/build.xml Tue May 14 15:40:24 2013
@@ -50,28 +50,6 @@
<!-- compile classes -->
<target name="compile">
<javac
- source="1.5"
- target="1.5"
- bootclasspath="${empty}"
- nowarn="on"
- debug="${debug}"
- depend="${depend}"
- deprecation="${deprecation}"
- optimize="${optimize}"
- proceed="${proceed}"
- verbose="${verbose}"
- srcdir="${derby.client.src.dir}"
- excludes="**/*40.java,**/*42.java"
- destdir="${out.dir}">
- <classpath>
- <pathelement path="${java15compile.classpath}"/>
- </classpath>
- <compilerarg value="-Xlint"/>
- </javac>
-</target>
-
-<target name="compile_jdbc4">
- <javac
source="${compilerLevel16}"
target="${compilerLevel16}"
bootclasspath="${empty}"
@@ -83,7 +61,8 @@
proceed="${proceed}"
verbose="${verbose}"
srcdir="${derby.client.src.dir}"
- includes="**/*40.java"
+ includes="**/*.java"
+ excludes="**/*42.java"
destdir="${out.dir}">
<classpath>
<pathelement path="${java16compile.classpath}"/>
@@ -115,7 +94,7 @@
</target>
<!-- default target -->
- <target name="client" depends="checkVMLevel, compile, compile_jdbc4, compile_jdbc42"/>
+ <target name="client" depends="checkVMLevel, compile, compile_jdbc42"/>
<target name="checkVMLevel">
<available classname="java.sql.SQLType" property="vmLevelIsAtLeast1.8" value="true"/>
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java?rev=1482405&r1=1482404&r2=1482405&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java Tue May 14 15:40:24 2013
@@ -25,16 +25,18 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.concurrent.CopyOnWriteArrayList;
import javax.sql.ConnectionEvent;
import javax.sql.ConnectionEventListener;
import javax.sql.PooledConnection;
+import javax.sql.StatementEvent;
+import javax.sql.StatementEventListener;
import org.apache.derby.client.am.ClientMessageId;
import org.apache.derby.client.am.ClientConnection;
import org.apache.derby.client.am.LogWriter;
import org.apache.derby.client.am.LogicalConnection;
import org.apache.derby.client.am.SqlException;
import org.apache.derby.client.am.stmtcache.JDBCStatementCache;
-import org.apache.derby.client.net.NetConnection;
import org.apache.derby.client.net.NetLogWriter;
import org.apache.derby.client.net.NetXAConnection;
import org.apache.derby.iapi.error.ExceptionSeverity;
@@ -85,6 +87,15 @@ public class ClientPooledConnection impl
protected int rmId_ = 0;
/**
+ * List of statement event listeners. The list is copied on each write,
+ * ensuring that it can be safely iterated over even if other threads or
+ * the listeners fired in the same thread add or remove listeners.
+ */
+ private final CopyOnWriteArrayList<StatementEventListener>
+ statementEventListeners =
+ new CopyOnWriteArrayList<StatementEventListener>();
+
+ /**
* Constructor for non-XA pooled connections.
* <p>
* Using standard Java APIs, a CPDS is passed in. Arguments for
@@ -431,41 +442,75 @@ public class ClientPooledConnection impl
public synchronized void nullLogicalConnection() {
logicalConnection_ = null;
}
-
- /*-----------------------------------------------------------------*/
- /*
- * These methods are needed to provide StatementEvent support for
- * derby.
- * They are actually implemented in EmbedPooledConnection40 but have
- * a dummy implementation here
+
+ // JDBC 4.0 methods
+
+ /**
+ * Registers a StatementEventListener with this PooledConnection object.
+ * Components that wish to be informed of events associated with the
+ * PreparedStatement object created by this PooledConnection like the close
+ * or error occurred event can register a StatementEventListener with this
+ * PooledConnection object.
+ *
+ * @param listener A component that implements the StatementEventListener
+ * interface and wants to be notified of Statement closed or or Statement
+ * error occurred events
*/
-
+ public void addStatementEventListener(StatementEventListener listener) {
+ if (logWriter_ != null) {
+ logWriter_.traceEntry(this, "addStatementEventListener", listener);
+ }
+ if (listener != null) {
+ statementEventListeners.add(listener);
+ }
+ }
+
/**
+ * Removes the specified previously registered listener object from the list
+ * of components that would be informed of events with a PreparedStatement
+ * object.
*
- * The onStatementClose contains the logic for raising the Statement Closed
- * events. This method has a dummy implementation here to avoid error when
- * this class is compiled with jdk1.4. The class the actual implementation
- * in ClientPooledConnection40.
+ * @param listener The previously registered event listener that needs to be
+ * removed from the list of components
+ */
+ public void removeStatementEventListener(StatementEventListener listener) {
+ if (logWriter_ != null) {
+ logWriter_.traceEntry(
+ this, "removeConnectionEventListener", listener);
+ }
+ statementEventListeners.remove(listener);
+ }
+
+ /**
+ * Raise the statementClosed event for all the listeners when the
+ * corresponding events occurs.
*
* @param statement The PreparedStatement that was closed
- *
*/
public void onStatementClose(PreparedStatement statement) {
-
+ if (!statementEventListeners.isEmpty()) {
+ StatementEvent event = new StatementEvent(this, statement);
+ for (StatementEventListener l : statementEventListeners) {
+ l.statementClosed(event);
+ }
+ }
}
-
+
/**
- * The method contains the logic for raising the Statement error occurred
- * events. This method has a dummy implementation here to avoid error when
- * this class is compiled with jdk1.4. The class the actual implementation
- * in ClientPooledConnection40.
+ * Raise the statementErrorOccurred event for all the listeners when the
+ * corresponding events occurs.
*
- * @param statement The PreparedStatement that was closed
- * @param sqle The SQLException associated with the error that caused
- * the invalidation of this PreparedStatement
+ * @param statement The PreparedStatement on which error occurred
+ * @param sqle The SQLException associated with the error that caused the
+ * invalidation of the PreparedStatements
*/
public void onStatementErrorOccurred(PreparedStatement statement,
- SQLException sqle) {
-
+ SQLException sqle) {
+ if (!statementEventListeners.isEmpty()) {
+ StatementEvent event = new StatementEvent(this, statement, sqle);
+ for (StatementEventListener l : statementEventListeners) {
+ l.statementErrorOccurred(event);
+ }
+ }
}
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientCallableStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientCallableStatement.java?rev=1482405&r1=1482404&r2=1482405&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientCallableStatement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientCallableStatement.java Tue May 14 15:40:24 2013
@@ -33,9 +33,12 @@ import java.sql.Blob;
import java.sql.CallableStatement;
import java.sql.Clob;
import java.sql.Date;
+import java.sql.NClob;
import java.sql.PreparedStatement;
import java.sql.Ref;
+import java.sql.RowId;
import java.sql.SQLException;
+import java.sql.SQLXML;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Calendar;
@@ -1191,6 +1194,216 @@ public class ClientCallableStatement ext
}
}
+ public final void setAsciiStream(String parameterName, InputStream x, long length)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("setAsciiStream(String,InputStream,long)");
+ }
+
+ public final void setBinaryStream(String parameterName, InputStream x, long length)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("setBinaryStream(String,InputStream,long)");
+ }
+
+ public final void setCharacterStream(String parameterName, Reader x, long length)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("setCharacterStream(String,Reader,long)");
+ }
+
+ public Reader getCharacterStream(String parameterName)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("getCharacterStream(String)");
+ }
+
+ public Reader getNCharacterStream(int parameterIndex)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("getNCharacterStream(int)");
+ }
+
+ public Reader getNCharacterStream(String parameterName)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented(
+ "getNCharacterStream(String)");
+ }
+
+ public String getNString(int parameterIndex)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("getNString(int)");
+ }
+
+ public String getNString(String parameterIndex)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("getNString(String)");
+ }
+
+ public RowId getRowId(int parameterIndex) throws SQLException {
+ throw SQLExceptionFactory.notImplemented("getRowId (int)");
+ }
+
+ public RowId getRowId(String parameterName) throws SQLException {
+ throw SQLExceptionFactory.notImplemented("getRowId (String)");
+ }
+
+ public void setRowId(String parameterName, RowId x) throws SQLException {
+ throw SQLExceptionFactory.notImplemented("setRowId (String, RowId)");
+ }
+
+ public void setBlob(String parameterName, Blob x)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("setBlob(String, Blob)");
+ }
+
+ public void setClob(String parameterName, Clob x)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("setClob(String, Clob)");
+ }
+
+ public void setNString(String parameterName, String value)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("setNString (String, String)");
+ }
+
+ public void setNCharacterStream(String parameterName, Reader value, long length)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented(
+ "setNString (String, Reader, long)");
+ }
+
+ public void setNClob(String parameterName, NClob value) throws SQLException {
+ throw SQLExceptionFactory.notImplemented("setNClob (String, NClob)");
+ }
+
+ public void setClob(String parameterName, Reader reader, long length)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("setClob (String, Reader, long)");
+ }
+
+ public void setBlob(String parameterName, InputStream inputStream, long length)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("setBlob (String, InputStream, long)");
+ }
+
+ public void setNClob(String parameterName, Reader reader, long length)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("setNClob (String, Reader, long)");
+ }
+
+ public NClob getNClob(int i) throws SQLException {
+ throw SQLExceptionFactory.notImplemented("setNClob (int)");
+ }
+
+ public NClob getNClob(String parameterName) throws SQLException {
+ throw SQLExceptionFactory.notImplemented("setNClob (String)");
+ }
+
+ public void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException {
+ throw SQLExceptionFactory.notImplemented("setSQLXML (String, SQLXML)");
+ }
+
+ public SQLXML getSQLXML(int parameterIndex) throws SQLException {
+ throw SQLExceptionFactory.notImplemented("getSQLXML (int)");
+ }
+
+ public SQLXML getSQLXML(String parametername) throws SQLException {
+ throw SQLExceptionFactory.notImplemented("getSQLXML (String)");
+ }
+ public void setAsciiStream(String parameterName, InputStream x)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented(
+ "setAsciiStream(String,InputStream)");
+ }
+
+ public void setBinaryStream(String parameterName, InputStream x)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented(
+ "setBinaryStream(String,InputStream)");
+ }
+
+ public void setBlob(String parameterName, InputStream inputStream)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented(
+ "setBlob(String,InputStream)");
+ }
+
+ public void setCharacterStream(String parameterName, Reader reader)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented(
+ "setCharacterStream(String,Reader)");
+ }
+
+ public void setClob(String parameterName, Reader reader)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("setClob(String,Reader)");
+ }
+
+ public void setNCharacterStream(String parameterName, Reader value)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented(
+ "setNCharacterStream(String,Reader)");
+ }
+
+ public void setNClob(String parameterName, Reader reader)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("setNClob(String,Reader)");
+ }
+
+ ////////////////////////////////////////////////////////////////////
+ //
+ // INTRODUCED BY JDBC 4.1 IN JAVA 7
+ //
+ ////////////////////////////////////////////////////////////////////
+
+ public <T> T getObject( int parameterIndex, Class<T> type )
+ throws SQLException
+ {
+ // checkForClosedStatement() should be called by all of the
+ // more specific methods to which we forward this call
+
+ if ( type == null )
+ {
+ throw mismatchException( "NULL", parameterIndex );
+ }
+
+ Object retval;
+
+ if ( String.class.equals( type ) ) { retval = getString( parameterIndex ); }
+ else if ( BigDecimal.class.equals( type ) ) { retval = getBigDecimal( parameterIndex ); }
+ else if ( Boolean.class.equals( type ) ) { retval = Boolean.valueOf( getBoolean(parameterIndex ) ); }
+ else if ( Byte.class.equals( type ) ) { retval = Byte.valueOf( getByte( parameterIndex ) ); }
+ else if ( Short.class.equals( type ) ) { retval = Short.valueOf( getShort( parameterIndex ) ); }
+ else if ( Integer.class.equals( type ) ) { retval = Integer.valueOf( getInt( parameterIndex ) ); }
+ else if ( Long.class.equals( type ) ) { retval = Long.valueOf( getLong( parameterIndex ) ); }
+ else if ( Float.class.equals( type ) ) { retval = Float.valueOf( getFloat( parameterIndex ) ); }
+ else if ( Double.class.equals( type ) ) { retval = Double.valueOf( getDouble( parameterIndex ) ); }
+ else if ( Date.class.equals( type ) ) { retval = getDate( parameterIndex ); }
+ else if ( Time.class.equals( type ) ) { retval = getTime( parameterIndex ); }
+ else if ( Timestamp.class.equals( type ) ) { retval = getTimestamp( parameterIndex ); }
+ else if ( Blob.class.equals( type ) ) { retval = getBlob( parameterIndex ); }
+ else if ( Clob.class.equals( type ) ) { retval = getClob( parameterIndex ); }
+ else if ( type.isArray() && type.getComponentType().equals( byte.class ) ) { retval = getBytes( parameterIndex ); }
+ else { retval = getObject( parameterIndex ); }
+
+ if ( wasNull() ) { retval = null; }
+
+ if ( (retval == null) || (type.isInstance( retval )) ) { return type.cast( retval ); }
+
+ throw mismatchException( type.getName(), parameterIndex );
+ }
+ private SQLException mismatchException( String targetTypeName, int parameterIndex )
+ throws SQLException
+ {
+ String sourceTypeName = getParameterMetaData().getParameterTypeName( parameterIndex );
+ ClientMessageId cmi = new ClientMessageId( SQLState.LANG_DATA_TYPE_GET_MISMATCH );
+ SqlException se = new SqlException( agent_.logWriter_, cmi, targetTypeName, sourceTypeName );
+
+ return se.getSQLException();
+ }
+
+ public <T> T getObject(String parameterName, Class<T> type)
+ throws SQLException
+ {
+ throw jdbcMethodNotImplemented();
+ }
+
//----------------------------overrides----------------------------------
public void completeExecuteCall(Sqlca sqlca, Cursor singletonParams) // no result sets returned
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientCallableStatement42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientCallableStatement42.java?rev=1482405&r1=1482404&r2=1482405&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientCallableStatement42.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientCallableStatement42.java Tue May 14 15:40:24 2013
@@ -26,7 +26,7 @@ import java.sql.SQLType;
import org.apache.derby.client.ClientPooledConnection;
-public class ClientCallableStatement42 extends ClientCallableStatement40
+public class ClientCallableStatement42 extends ClientCallableStatement
{
/**
* Calls the superclass constructor and passes the parameters
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientConnection.java?rev=1482405&r1=1482404&r2=1482405&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientConnection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientConnection.java Tue May 14 15:40:24 2013
@@ -29,6 +29,7 @@ import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.SQLPermission;
import java.sql.SQLWarning;
import java.sql.Savepoint;
import java.sql.Statement;
@@ -40,6 +41,7 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.WeakHashMap;
+import java.util.concurrent.Executor;
import org.apache.derby.client.net.NetXAResource;
import org.apache.derby.jdbc.ClientBaseDataSourceRoot;
import org.apache.derby.shared.common.reference.SQLState;
@@ -2683,4 +2685,64 @@ public abstract class ClientConnection
}
}
+ public void abort( Executor executor ) throws SQLException
+ {
+ // NOP if called on a closed connection.
+ if ( !open_ ) { return; }
+ // Null executor not allowed.
+ if ( executor == null )
+ {
+ ClientMessageId cmi = new ClientMessageId( SQLState.UU_INVALID_PARAMETER );
+ SqlException se = new SqlException( agent_.logWriter_, cmi, "executor", "null" );
+
+ throw se.getSQLException();
+ }
+
+ //
+ // Must have privilege to invoke this method.
+ //
+ // The derby jars should be granted this permission. We deliberately
+ // do not wrap this check in an AccessController.doPrivileged() block.
+ // If we did so, that would absolve outer code blocks of the need to
+ // have this permission granted to them too. It is critical that the
+ // outer code blocks enjoy this privilege. That is what allows
+ // connection pools to prevent ordinary code from calling abort()
+ // and restrict its usage to privileged tools.
+ //
+ SecurityManager securityManager = System.getSecurityManager();
+ if ( securityManager != null )
+ { securityManager.checkPermission( new SQLPermission( "callAbort" ) ); }
+
+ // Mark the Connection as closed. Set the "aborting" flag to allow internal
+ // processing in close() to proceed.
+ beginAborting();
+
+ //
+ // Now pass the Executor a Runnable which does the real work.
+ //
+ executor.execute
+ (
+ new Runnable()
+ {
+ public void run()
+ {
+ try {
+ rollback();
+ close();
+ } catch (SQLException se) { se.printStackTrace( agent_.getLogWriter() ); }
+ }
+ }
+ );
+ }
+
+ public int getNetworkTimeout() throws SQLException
+ {
+ throw SQLExceptionFactory.notImplemented("getNetworkTimeout");
+ }
+
+ public void setNetworkTimeout( Executor executor, int milliseconds ) throws SQLException
+ {
+ throw SQLExceptionFactory.notImplemented("setNetworkTimeout");
+ }
+
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientDatabaseMetaData.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientDatabaseMetaData.java?rev=1482405&r1=1482404&r2=1482405&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientDatabaseMetaData.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientDatabaseMetaData.java Tue May 14 15:40:24 2013
@@ -24,6 +24,7 @@ package org.apache.derby.client.am;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
+import java.sql.RowIdLifetime;
import java.sql.SQLException;
import java.sql.Types;
import java.util.StringTokenizer;
@@ -2295,12 +2296,12 @@ public abstract class ClientDatabaseMeta
public int getJDBCMajorVersion() throws SQLException {
checkForClosedConnection();
- return 3;
+ return 4;
}
public int getJDBCMinorVersion() throws SQLException {
checkForClosedConnection();
- return 0;
+ return 1;
}
public int getSQLStateType() throws SQLException {
@@ -2867,6 +2868,53 @@ public abstract class ClientDatabaseMeta
return ps.executeQueryX();
}
+ /**
+ * Indicates whether or not this data source supports the SQL
+ * <code>ROWID</code> type. Since Derby does not support the
+ * <code>ROWID</code> type, return <code>ROWID_UNSUPPORTED</code>.
+ *
+ * @return <code>ROWID_UNSUPPORTED</code>
+ * @exception SQLException if a database access error occurs
+ */
+ public RowIdLifetime getRowIdLifetime() throws SQLException {
+ checkForClosedConnection();
+ return RowIdLifetime.ROWID_UNSUPPORTED;
+ }
+
+ /**
+ * Returns false unless <code>interfaces</code> is implemented
+ *
+ * @param interfaces a Class defining an interface.
+ * @return true if this implements the interface or
+ * directly or indirectly wraps an object
+ * that does.
+ * @throws java.sql.SQLException if an error occurs while determining
+ * whether this is a wrapper for an object
+ * with the given interface.
+ */
+ public boolean isWrapperFor(Class<?> interfaces) throws SQLException {
+ return interfaces.isInstance(this);
+ }
+
+ /**
+ * Returns <code>this</code> if this class implements the interface
+ *
+ * @param interfaces a Class defining an interface
+ * @return an object that implements the interface
+ * @throws SQLException if no object if found that implements the
+ * interface
+ */
+ public <T> T unwrap(Class<T> interfaces)
+ throws SQLException {
+ try {
+ return interfaces.cast(this);
+ } catch (ClassCastException cce) {
+ throw new SqlException(null,
+ new ClientMessageId(SQLState.UNABLE_TO_UNWRAP),
+ interfaces).getSQLException();
+ }
+ }
+
// ------------------- JDBC 4.1 -------------------------
/** See DatabaseMetaData javadoc */
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientPreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientPreparedStatement.java?rev=1482405&r1=1482404&r2=1482405&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientPreparedStatement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientPreparedStatement.java Tue May 14 15:40:24 2013
@@ -31,12 +31,15 @@ import java.sql.BatchUpdateException;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Date;
+import java.sql.NClob;
import java.sql.ParameterMetaData;
import java.sql.PreparedStatement;
import java.sql.Ref;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
+import java.sql.RowId;
import java.sql.SQLException;
+import java.sql.SQLXML;
import java.sql.Time;
import java.sql.Timestamp;
import java.sql.Types;
@@ -2705,6 +2708,19 @@ public class ClientPreparedStatement ext
throw SQLExceptionFactory.notImplemented("setNClob(int, Reader, long)");
}
+ public void setRowId(int parameterIndex, RowId x) throws SQLException {
+ throw SQLExceptionFactory.notImplemented("setRowId (int, RowId)");
+ }
+
+ public void setNClob(int index, NClob value) throws SQLException {
+ throw SQLExceptionFactory.notImplemented("setNClob (int, NClob)");
+ }
+
+ public void setSQLXML(int parameterIndex, SQLXML xmlObject)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("setSQLXML (int, SQLXML)");
+ }
+
// End of JDBC 4.0 methods
// Beginning of JDBC 4.2 methods
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientPreparedStatement42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientPreparedStatement42.java?rev=1482405&r1=1482404&r2=1482405&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientPreparedStatement42.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientPreparedStatement42.java Tue May 14 15:40:24 2013
@@ -25,7 +25,7 @@ import java.sql.SQLException;
import java.sql.SQLType;
import org.apache.derby.client.ClientPooledConnection;
-public class ClientPreparedStatement42 extends ClientPreparedStatement40
+public class ClientPreparedStatement42 extends ClientPreparedStatement
{
/**
* The PreparedStatement used for JDBC 4.2 positioned update statements.
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientResultSet.java?rev=1482405&r1=1482404&r2=1482405&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientResultSet.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientResultSet.java Tue May 14 15:40:24 2013
@@ -32,11 +32,15 @@ import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Date;
+import java.sql.NClob;
import java.sql.Ref;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
+import java.sql.RowId;
import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
import java.sql.SQLWarning;
+import java.sql.SQLXML;
import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;
@@ -6309,4 +6313,283 @@ public abstract class ClientResultSet im
this.lobState = LOBStateTracker.NO_OP_TRACKER;
}
}
+
+ public Reader getNCharacterStream(int columnIndex)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("getNCharacterStream(int)");
+ }
+
+ public Reader getNCharacterStream(String columnName)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("getNCharacterStream(String)");
+ }
+
+ public String getNString(int columnIndex)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("getNString(int)");
+ }
+
+ public String getNString(String columnName)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("getNString(String)");
+ }
+
+ public RowId getRowId(int columnIndex) throws SQLException {
+ throw SQLExceptionFactory.notImplemented ("getRowId (int)");
+ }
+
+
+ public RowId getRowId(String columnName) throws SQLException {
+ throw SQLExceptionFactory.notImplemented ("getRowId (String)");
+ }
+
+ public void updateRowId(int columnIndex, RowId x) throws SQLException {
+ throw SQLExceptionFactory.notImplemented ("updateRowId (int, RowId)");
+ }
+
+ public void updateRowId(String columnName, RowId x) throws SQLException {
+ throw SQLExceptionFactory.notImplemented ("updateRowId (String, RowId)");
+ }
+
+ public void updateNString(int columnIndex, String nString) throws SQLException {
+ throw SQLExceptionFactory.notImplemented ("updateNString (int, String)");
+ }
+
+ public void updateNString(String columnName, String nString) throws SQLException {
+ throw SQLExceptionFactory.notImplemented ("updateNString (String, String)");
+ }
+
+ public void updateNCharacterStream(int columnIndex, Reader x, long length)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented(
+ "updateNCharacterStream(int,Reader,long)");
+ }
+
+ public void updateNCharacterStream(String columnName, Reader x, long length)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented(
+ "updateNCharacterStream(String,Reader,long)");
+ }
+
+ public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
+ throw SQLExceptionFactory.notImplemented ("updateNClob (int, NClob)");
+ }
+
+ public void updateNClob(String columnName, NClob nClob) throws SQLException {
+ throw SQLExceptionFactory.notImplemented ("updateNClob (String, NClob)");
+ }
+
+ public NClob getNClob(int i) throws SQLException {
+ throw SQLExceptionFactory.notImplemented ("getNClob (int)");
+ }
+
+ public NClob getNClob(String colName) throws SQLException {
+ throw SQLExceptionFactory.notImplemented ("getNClob (String)");
+ }
+
+ public SQLXML getSQLXML(int columnIndex) throws SQLException {
+ throw SQLExceptionFactory.notImplemented ("getSQLXML (int)");
+ }
+
+ public SQLXML getSQLXML(String colName) throws SQLException {
+ throw SQLExceptionFactory.notImplemented ("getSQLXML (String)");
+ }
+
+ public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
+ throw SQLExceptionFactory.notImplemented ("updateSQLXML (int, SQLXML)");
+ }
+
+ public void updateSQLXML(String columnName, SQLXML xmlObject) throws SQLException {
+ throw SQLExceptionFactory.notImplemented ("updateSQLXML (String, SQLXML)");
+ }
+
+ /**
+ * Returns false unless <code>interfaces</code> is implemented
+ *
+ * @param interfaces a Class defining an interface.
+ * @return true if this implements the interface or
+ * directly or indirectly wraps an object
+ * that does.
+ * @throws java.sql.SQLException if an error occurs while determining
+ * whether this is a wrapper for an object
+ * with the given interface.
+ */
+ public boolean isWrapperFor(Class<?> interfaces) throws SQLException {
+ try {
+ checkForClosedResultSet("isWrapperFor");
+ } catch (SqlException se) {
+ throw se.getSQLException();
+ }
+ return interfaces.isInstance(this);
+ }
+
+ /**
+ * Returns <code>this</code> if this class implements the interface
+ *
+ * @param interfaces a Class defining an interface
+ * @return an object that implements the interface
+ * @throws java.sql.SQLExption if no object if found that implements the
+ * interface
+ */
+ public <T> T unwrap(Class<T> interfaces)
+ throws SQLException {
+ try {
+ checkForClosedResultSet("unwrap");
+ return interfaces.cast(this);
+ } catch (ClassCastException cce) {
+ throw new SqlException(null,
+ new ClientMessageId(SQLState.UNABLE_TO_UNWRAP),
+ interfaces).getSQLException();
+ } catch (SqlException se) {
+ throw se.getSQLException();
+ }
+ }
+
+
+ /**
+ * Updates the designated column with a java.sql.NClob value. The updater
+ * methods are used to update column values in the current row or the insert
+ * row. The updater methods do not update the underlying database; instead
+ * the updateRow or insertRow methods are called to update the database.
+ *
+ * @param columnIndex -
+ * the first column is 1, the second is 2
+ * @param x -
+ * the new column value
+ * @exception SQLException
+ * Feature not implemented for now.
+ */
+ public void updateNClob(int columnIndex, Reader x, long length)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("updateNClob(int,Reader,long)");
+ }
+
+ /**
+ * Updates the designated column with a java.sql.NClob value. The updater
+ * methods are used to update column values in the current row or the insert
+ * row. The updater methods do not update the underlying database; instead
+ * the updateRow or insertRow methods are called to update the database.
+ *
+ * @param columnName -
+ * the name of the Clob column
+ * @param x -
+ * the new column value
+ * @exception SQLException
+ * Feature not implemented for now.
+ */
+
+ public void updateNClob(String columnName, InputStream x, long length)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("updateNClob(String,InputStream,long)");
+ }
+
+ /**
+ * Updates the designated column with a java.sql.NClob value. The updater
+ * methods are used to update column values in the current row or the insert
+ * row. The updater methods do not update the underlying database; instead
+ * the updateRow or insertRow methods are called to update the database.
+ *
+ * @param columnName -
+ * the name of the Clob column
+ * @param x -
+ * the new column value
+ * @exception SQLException
+ * Feature not implemented for now.
+ */
+
+ public void updateNClob(String columnName, Reader x, long length)
+ throws SQLException {
+ throw SQLExceptionFactory.notImplemented("updateNClob(String,Reader,long)");
+ }
+
+ ////////////////////////////////////////////////////////////////////
+ //
+ // INTRODUCED BY JDBC 4.1 IN JAVA 7
+ //
+ ////////////////////////////////////////////////////////////////////
+
+ /**
+ * Retrieve the column as an object of the desired type.
+ */
+ public <T> T getObject( int columnIndex, Class<T> type )
+ throws SQLException
+ {
+ try {
+ checkForClosedResultSet("getObject");
+ } catch (SqlException se) {
+ throw se.getSQLException();
+ }
+
+ // closeCloseFilterInputStream() should be called by all of the
+ // more specific methods to which we forward this call
+
+ if (agent_.loggingEnabled()) {
+ agent_.logWriter_.traceEntry(this, "getObject", columnIndex );
+ }
+
+ if ( type == null )
+ {
+ throw mismatchException( "NULL", columnIndex );
+ }
+
+ Object retval;
+
+ if ( String.class.equals( type ) ) { retval = getString( columnIndex ); }
+ else if ( BigDecimal.class.equals( type ) ) { retval = getBigDecimal( columnIndex ); }
+ else if ( Boolean.class.equals( type ) ) { retval = Boolean.valueOf( getBoolean(columnIndex ) ); }
+ else if ( Byte.class.equals( type ) ) { retval = Byte.valueOf( getByte( columnIndex ) ); }
+ else if ( Short.class.equals( type ) ) { retval = Short.valueOf( getShort( columnIndex ) ); }
+ else if ( Integer.class.equals( type ) ) { retval = Integer.valueOf( getInt( columnIndex ) ); }
+ else if ( Long.class.equals( type ) ) { retval = Long.valueOf( getLong( columnIndex ) ); }
+ else if ( Float.class.equals( type ) ) { retval = Float.valueOf( getFloat( columnIndex ) ); }
+ else if ( Double.class.equals( type ) ) { retval = Double.valueOf( getDouble( columnIndex ) ); }
+ else if ( Date.class.equals( type ) ) { retval = getDate( columnIndex ); }
+ else if ( Time.class.equals( type ) ) { retval = getTime( columnIndex ); }
+ else if ( Timestamp.class.equals( type ) ) { retval = getTimestamp( columnIndex ); }
+
+ else if ( Blob.class.equals( type ) ) {
+ retval = getBlob( columnIndex );
+
+ } else if ( Clob.class.equals( type ) ) {
+ retval = getClob( columnIndex );
+
+ } else if ( type.isArray() &&
+ type.getComponentType().equals( byte.class ) ) {
+ retval = getBytes( columnIndex );
+
+ } else { retval = getObject( columnIndex );
+ }
+
+ if ( wasNull() ) { retval = null; }
+
+ if ( (retval == null) || (type.isInstance( retval )) ) { return type.cast( retval ); }
+
+ throw mismatchException( type.getName(), columnIndex );
+ }
+ private SQLException mismatchException( String targetTypeName, int columnIndex )
+ throws SQLException
+ {
+ String sourceTypeName = getMetaData().getColumnTypeName( columnIndex );
+ ClientMessageId cmi = new ClientMessageId( SQLState.LANG_DATA_TYPE_GET_MISMATCH );
+ SqlException se = new SqlException( agent_.logWriter_, cmi, targetTypeName, sourceTypeName );
+
+ return se.getSQLException();
+ }
+
+ public <T> T getObject( String columnName, Class<T> type )
+ throws SQLException
+ {
+ try
+ {
+ if (agent_.loggingEnabled()) {
+ agent_.logWriter_.traceEntry(this, "getObject", columnName);
+ }
+ return getObject( findColumnX(columnName, "getObject"), type );
+ }
+ catch ( SqlException se )
+ {
+ throw se.getSQLException();
+ }
+ }
+
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java?rev=1482405&r1=1482404&r2=1482405&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java Tue May 14 15:40:24 2013
@@ -156,20 +156,6 @@ public class Configuration {
}
/**
- * Check to see if the jvm version is such that JDBC 4.0 is supported
- */
-
- public static boolean supportsJDBC40() {
- // use reflection to identify whether we support JDBC40
- try {
- Class.forName("java.sql.SQLXML");
- return true;
- } catch (Exception e) {
- return false;
- }
- }
-
- /**
* Check to see if the jvm version is such that JDBC 4.2 is supported
*/
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement.java?rev=1482405&r1=1482404&r2=1482405&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement.java Tue May 14 15:40:24 2013
@@ -29,8 +29,11 @@ import java.sql.Blob;
import java.sql.CallableStatement;
import java.sql.Clob;
import java.sql.Date;
+import java.sql.NClob;
import java.sql.Ref;
+import java.sql.RowId;
import java.sql.SQLException;
+import java.sql.SQLXML;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Calendar;
@@ -384,4 +387,191 @@ public class LogicalCallableStatement
public void setTimestamp(String parameterName, Timestamp x, Calendar cal) throws SQLException {
getPhysCs().setTimestamp(parameterName, x, cal);
}
+
+ ////////////////////////////////////////////////////////////////////
+ //
+ // INTRODUCED BY JDBC 4.0 IN JAVA 6
+ //
+ ////////////////////////////////////////////////////////////////////
+
+ public RowId getRowId(int arg0)
+ throws SQLException {
+ return getPhysCs().getRowId(arg0);
+ }
+
+ public RowId getRowId(String arg0)
+ throws SQLException {
+ return getPhysCs().getRowId(arg0);
+ }
+
+ public void setRowId(String arg0, RowId arg1)
+ throws SQLException {
+ getPhysCs().setRowId(arg0, arg1);
+ }
+
+ public void setNString(String arg0, String arg1)
+ throws SQLException {
+ getPhysCs().setNString(arg0, arg1);
+ }
+
+ public void setNCharacterStream(String arg0, Reader arg1, long arg2)
+ throws SQLException {
+ getPhysCs().setNCharacterStream(arg0, arg1, arg2);
+ }
+
+ public void setNClob(String arg0, NClob arg1)
+ throws SQLException {
+ getPhysCs().setNClob(arg0, arg1);
+ }
+
+ public void setClob(String arg0, Reader arg1, long arg2)
+ throws SQLException {
+ getPhysCs().setClob(arg0, arg1, arg2);
+ }
+
+ public void setBlob(String arg0, InputStream arg1, long arg2)
+ throws SQLException {
+ getPhysCs().setBlob(arg0, arg1, arg2);
+ }
+
+ public void setNClob(String arg0, Reader arg1, long arg2)
+ throws SQLException {
+ getPhysCs().setNClob(arg0, arg1, arg2);
+ }
+
+ public NClob getNClob(int arg0)
+ throws SQLException {
+ return getPhysCs().getNClob(arg0);
+ }
+
+ public NClob getNClob(String arg0)
+ throws SQLException {
+ return getPhysCs().getNClob(arg0);
+ }
+
+ public void setSQLXML(String arg0, SQLXML arg1)
+ throws SQLException {
+ getPhysCs().setSQLXML(arg0, arg1);
+ }
+
+ public SQLXML getSQLXML(int arg0)
+ throws SQLException {
+ return getPhysCs().getSQLXML(arg0);
+ }
+
+ public SQLXML getSQLXML(String arg0)
+ throws SQLException {
+ return getPhysCs().getSQLXML(arg0);
+ }
+
+ public String getNString(int arg0)
+ throws SQLException {
+ return getPhysCs().getNString(arg0);
+ }
+
+ public String getNString(String arg0)
+ throws SQLException {
+ return getPhysCs().getNString(arg0);
+ }
+
+ public Reader getNCharacterStream(int arg0)
+ throws SQLException {
+ return getPhysCs().getNCharacterStream(arg0);
+ }
+
+ public Reader getNCharacterStream(String arg0)
+ throws SQLException {
+ return getPhysCs().getNCharacterStream(arg0);
+ }
+
+ public Reader getCharacterStream(int arg0)
+ throws SQLException {
+ return getPhysCs().getCharacterStream(arg0);
+ }
+
+ public Reader getCharacterStream(String arg0)
+ throws SQLException {
+ return getPhysCs().getCharacterStream(arg0);
+ }
+
+ public void setBlob(String arg0, Blob arg1)
+ throws SQLException {
+ getPhysCs().setBlob(arg0, arg1);
+ }
+
+ public void setClob(String arg0, Clob arg1)
+ throws SQLException {
+ getPhysCs().setClob(arg0, arg1);
+ }
+
+ public void setAsciiStream(String arg0, InputStream arg1, long arg2)
+ throws SQLException {
+ getPhysCs().setAsciiStream(arg0, arg1, arg2);
+ }
+
+ public void setBinaryStream(String arg0, InputStream arg1, long arg2)
+ throws SQLException {
+ getPhysCs().setBinaryStream(arg0, arg1, arg2);
+ }
+
+ public void setCharacterStream(String arg0, Reader arg1, long arg2)
+ throws SQLException {
+ getPhysCs().setCharacterStream(arg0, arg1, arg2);
+ }
+
+ public void setAsciiStream(String arg0, InputStream arg1)
+ throws SQLException {
+ getPhysCs().setAsciiStream(arg0, arg1);
+ }
+
+ public void setBinaryStream(String arg0, InputStream arg1)
+ throws SQLException {
+ getPhysCs().setBinaryStream(arg0, arg1);
+ }
+
+ public void setCharacterStream(String arg0, Reader arg1)
+ throws SQLException {
+ getPhysCs().setCharacterStream(arg0, arg1);
+ }
+
+ public void setNCharacterStream(String arg0, Reader arg1)
+ throws SQLException {
+ getPhysCs().setNCharacterStream(arg0, arg1);
+ }
+
+ public void setClob(String arg0, Reader arg1)
+ throws SQLException {
+ getPhysCs().setClob(arg0, arg1);
+ }
+
+ public void setBlob(String arg0, InputStream arg1)
+ throws SQLException {
+ getPhysCs().setBlob(arg0, arg1);
+ }
+
+ public void setNClob(String arg0, Reader arg1)
+ throws SQLException {
+ getPhysCs().setNClob(arg0, arg1);
+ }
+
+ ////////////////////////////////////////////////////////////////////
+ //
+ // INTRODUCED BY JDBC 4.1 IN JAVA 7
+ //
+ ////////////////////////////////////////////////////////////////////
+
+ public <T> T getObject( int parameterIndex, Class<T> type )
+ throws SQLException
+ {
+ return ((ClientCallableStatement) getPhysCs()).
+ getObject(parameterIndex, type);
+ }
+
+ public <T> T getObject(String parameterName, Class<T> type)
+ throws SQLException
+ {
+ return ((ClientCallableStatement) getPhysCs()).
+ getObject( parameterName, type );
+ }
+
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement42.java?rev=1482405&r1=1482404&r2=1482405&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement42.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement42.java Tue May 14 15:40:24 2013
@@ -31,7 +31,7 @@ import org.apache.derby.client.am.stmtca
* @see LogicalCallableStatement
* @see #isClosed
*/
-public class LogicalCallableStatement42 extends LogicalCallableStatement40
+public class LogicalCallableStatement42 extends LogicalCallableStatement
{
/**
* Creates a new logical callable statement.
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection.java?rev=1482405&r1=1482404&r2=1482405&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection.java Tue May 14 15:40:24 2013
@@ -21,15 +21,24 @@
package org.apache.derby.client.am;
+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.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.Map;
+import java.util.Properties;
+import java.util.concurrent.Executor;
import org.apache.derby.client.ClientPooledConnection;
import org.apache.derby.shared.common.reference.SQLState;
@@ -640,6 +649,241 @@ public class LogicalConnection implement
////////////////////////////////////////////////////////////////////
//
+ // INTRODUCED BY JDBC 4.0 IN JAVA 6
+ //
+ ////////////////////////////////////////////////////////////////////
+ public Array createArrayOf(String typeName, Object[] elements)
+ throws SQLException {
+ try
+ {
+ checkForNullPhysicalConnection();
+ return physicalConnection_.createArrayOf( typeName, elements );
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+ public Blob createBlob()
+ throws SQLException {
+ try
+ {
+ checkForNullPhysicalConnection();
+ return physicalConnection_.createBlob();
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+ public Clob createClob()
+ throws SQLException {
+ try
+ {
+ checkForNullPhysicalConnection();
+ return physicalConnection_.createClob();
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+ public NClob createNClob()
+ throws SQLException {
+ try
+ {
+ checkForNullPhysicalConnection();
+ return physicalConnection_.createNClob();
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+ public SQLXML createSQLXML()
+ throws SQLException {
+ try
+ {
+ checkForNullPhysicalConnection();
+ return physicalConnection_.createSQLXML();
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+ public Struct createStruct(String typeName, Object[] attributes)
+ throws SQLException {
+ try
+ {
+ checkForNullPhysicalConnection();
+ return physicalConnection_.createStruct( typeName, attributes );
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+ /**
+ * <code>getClientInfo</code> forwards to
+ * <code>physicalConnection_</code>.
+ * <code>getClientInfo</code> always returns an empty
+ * <code>Properties</code> object since Derby doesn't support
+ * ClientInfoProperties.
+ *
+ * @return an empty <code>Properties</code> object
+ * @exception SQLException if an error occurs
+ */
+ public Properties getClientInfo()
+ throws SQLException {
+ try
+ {
+ checkForNullPhysicalConnection();
+ return physicalConnection_.getClientInfo();
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+ /**
+ * <code>getClientInfo</code> forwards to
+ * <code>physicalConnection_</code>. Always returns a <code>null
+ * String</code> since Derby does not support
+ * ClientInfoProperties.
+ *
+ * @param name a property key to get <code>String</code>
+ * @return a property value <code>String</code>
+ * @exception SQLException if an error occurs
+ */
+ public String getClientInfo(String name)
+ throws SQLException {
+ try
+ {
+ checkForNullPhysicalConnection();
+ return physicalConnection_.getClientInfo(name);
+ } 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.
+ */
+ synchronized public boolean isValid(int timeout) throws SQLException {
+ try
+ {
+ // Check if we have a underlying physical connection
+ if (physicalConnection_ == null) {
+ return false;
+ }
+ return physicalConnection_.isValid(timeout);
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+
+ public boolean isWrapperFor(Class<?> interfaces)
+ throws SQLException {
+ try
+ {
+ checkForNullPhysicalConnection();
+ return interfaces.isInstance(this);
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+ /**
+ * <code>setClientInfo</code> forwards to
+ * <code>physicalConnection_</code>.
+ *
+ * @param properties a <code>Properties</code> object with the
+ * properties to set
+ * @exception SQLClientInfoException if an error occurs
+ */
+ public void setClientInfo(Properties properties)
+ throws SQLClientInfoException {
+ try
+ {
+ checkForNullPhysicalConnection();
+ physicalConnection_.setClientInfo(properties);
+ } catch (SQLClientInfoException cie) {
+ notifyException(cie);
+ throw cie;
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw new SQLClientInfoException
+ (sqle.getMessage(), sqle.getSQLState(),
+ sqle.getErrorCode(),
+ (new FailedProperties40(properties)).getProperties());
+ }
+ }
+
+ /**
+ * <code>setClientInfo</code> forwards to
+ * <code>physicalConnection_</code>.
+ *
+ * @param name a property key <code>String</code>
+ * @param value a property value <code>String</code>
+ * @exception SQLException if an error occurs
+ */
+ public void setClientInfo(String name, String value)
+ throws SQLClientInfoException {
+ try
+ {
+ checkForNullPhysicalConnection();
+ physicalConnection_.setClientInfo(name, value);
+ } catch (SQLClientInfoException cie) {
+ notifyException(cie);
+ throw cie;
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw new SQLClientInfoException
+ (sqle.getMessage(), sqle.getSQLState(),
+ sqle.getErrorCode(),
+ new FailedProperties40
+ (FailedProperties40.makeProperties
+ (name,value)).getProperties());
+ }
+ }
+
+ public <T>T unwrap(Class<T> interfaces)
+ throws SQLException {
+ try
+ {
+ checkForNullPhysicalConnection();
+ // Derby does not implement non-standard methods on JDBC objects
+ try {
+ return interfaces.cast(this);
+ } catch (ClassCastException cce) {
+ throw new SqlException(null,
+ new ClientMessageId(SQLState.UNABLE_TO_UNWRAP),
+ interfaces).getSQLException();
+ }
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+ ////////////////////////////////////////////////////////////////////
+ //
// INTRODUCED BY JDBC 4.1 IN JAVA 7
//
////////////////////////////////////////////////////////////////////
@@ -671,5 +915,43 @@ public class LogicalConnection implement
throw sqle;
}
}
-
+
+ public void abort( Executor executor ) throws SQLException
+ {
+ try
+ {
+ if ( physicalConnection_ != null )
+ {
+ physicalConnection_.abort( executor );
+ }
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+ public int getNetworkTimeout() throws SQLException
+ {
+ try
+ {
+ checkForNullPhysicalConnection();
+ return physicalConnection_.getNetworkTimeout();
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
+ public void setNetworkTimeout( Executor executor, int milliseconds ) throws SQLException
+ {
+ try
+ {
+ checkForNullPhysicalConnection();
+ physicalConnection_.setNetworkTimeout( executor, milliseconds );
+ } catch (SQLException sqle) {
+ notifyException(sqle);
+ throw sqle;
+ }
+ }
+
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalDatabaseMetaData.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalDatabaseMetaData.java?rev=1482405&r1=1482404&r2=1482405&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalDatabaseMetaData.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalDatabaseMetaData.java Tue May 14 15:40:24 2013
@@ -23,7 +23,9 @@ package org.apache.derby.client.am;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
+import java.sql.RowIdLifetime;
import java.sql.SQLException;
+import org.apache.derby.shared.common.reference.SQLState;
/**
* A metadata object to be used with logical connections when connection
@@ -39,7 +41,7 @@ class LogicalDatabaseMetaData implements
/** The associated logical connection. */
private final LogicalConnection logicalCon;
/** Error message destination, if any. */
- final LogWriter logWriter;
+ private final LogWriter logWriter;
/** Cached value for the driver major version. */
private final int driverMajorVersion;
/** Cached value for the driver minor version. */
@@ -819,4 +821,113 @@ class LogicalDatabaseMetaData implements
public boolean supportsStatementPooling() throws SQLException {
return getRealMetaDataObject().supportsStatementPooling();
}
+
+ // JDBC 4.0 methods
+
+ public boolean autoCommitFailureClosesAllResultSets()
+ throws SQLException {
+ return getRealMetaDataObject().autoCommitFailureClosesAllResultSets();
+ }
+
+ public ResultSet getClientInfoProperties()
+ throws SQLException {
+ return getRealMetaDataObject().getClientInfoProperties();
+ }
+
+ public ResultSet getFunctions(String catalog, String schemaPattern,
+ String functionNamePattern)
+ throws SQLException {
+ return getRealMetaDataObject().getFunctions(
+ catalog, schemaPattern, functionNamePattern);
+ }
+
+ public ResultSet getFunctionColumns(
+ String catalog, String schemaPattern,
+ String functionNamePattern,
+ String columnNamePattern) throws SQLException {
+
+ return getRealMetaDataObject().getFunctionColumns(
+ catalog, schemaPattern, functionNamePattern, columnNamePattern);
+ }
+
+ public RowIdLifetime getRowIdLifetime()
+ throws SQLException {
+ return getRealMetaDataObject().getRowIdLifetime();
+ }
+
+ public ResultSet getSchemas(String catalog, String schemaPattern)
+ throws SQLException {
+ return getRealMetaDataObject().getSchemas(catalog, schemaPattern);
+ }
+
+ public boolean isWrapperFor(Class<?> interfaces)
+ throws SQLException {
+ getRealMetaDataObject(); // Check for open connection.
+ return interfaces.isInstance(this);
+ }
+
+ public boolean supportsStoredFunctionsUsingCallSyntax()
+ throws SQLException {
+ return getRealMetaDataObject().supportsStoredFunctionsUsingCallSyntax();
+ }
+
+ public <T> T unwrap(Class<T> interfaces)
+ throws SQLException {
+ getRealMetaDataObject(); // Check for open connection.
+ try {
+ return interfaces.cast(this);
+ } catch (ClassCastException cce) {
+ throw new SqlException(
+ logWriter,
+ new ClientMessageId(SQLState.UNABLE_TO_UNWRAP),
+ interfaces
+ ).getSQLException();
+ }
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ //
+ // JDBC 4.1 - New public methods
+ //
+ /////////////////////////////////////////////////////////////////////////
+
+ /** See DatabaseMetaData javadoc */
+ public boolean generatedKeyAlwaysReturned() throws SQLException
+ {
+ return ((ClientDatabaseMetaData)getRealMetaDataObject()).
+ generatedKeyAlwaysReturned();
+ }
+
+ /**
+ * See DatabaseMetaData javadoc. Empty ResultSet because Derby does
+ * not support pseudo columns.
+ */
+ public ResultSet getPseudoColumns
+ ( String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern )
+ throws SQLException
+ {
+ return ((ClientDatabaseMetaData)getRealMetaDataObject()).
+ getPseudoColumns(catalog,
+ schemaPattern,
+ tableNamePattern,
+ columnNamePattern);
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ //
+ // JDBC 4.2 - New public methods
+ //
+ /////////////////////////////////////////////////////////////////////////
+
+ /** See DatabaseMetaData javadoc */
+ public long getMaxLogicalLobSize() throws SQLException
+ {
+ return ((ClientDatabaseMetaData)getRealMetaDataObject()).
+ getMaxLogicalLobSize();
+ }
+ public boolean supportsRefCursors() throws SQLException
+ {
+ return ((ClientDatabaseMetaData)getRealMetaDataObject()).
+ supportsRefCursors();
+ }
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalPreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalPreparedStatement.java?rev=1482405&r1=1482404&r2=1482405&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalPreparedStatement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalPreparedStatement.java Tue May 14 15:40:24 2013
@@ -31,13 +31,16 @@ import java.sql.Blob;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.Date;
+import java.sql.NClob;
import java.sql.ParameterMetaData;
import java.sql.PreparedStatement;
import java.sql.Ref;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
+import java.sql.RowId;
import java.sql.SQLException;
import java.sql.SQLWarning;
+import java.sql.SQLXML;
import java.sql.Time;
import java.sql.Timestamp;
@@ -389,6 +392,123 @@ public class LogicalPreparedStatement
////////////////////////////////////////////////////////////////
//
+ // ADDED BY JDBC 4.0
+ //
+ ////////////////////////////////////////////////////////////////
+
+ public void setRowId(int arg0, RowId arg1)
+ throws SQLException {
+ getPhysPs().setRowId(arg0, arg1);
+ }
+
+ public void setNString(int arg0, String arg1)
+ throws SQLException {
+ getPhysPs().setNString(arg0, arg1);
+ }
+
+ public void setNCharacterStream(int arg0, Reader arg1, long arg2)
+ throws SQLException {
+ getPhysPs().setNCharacterStream(arg0, arg1, arg2);
+ }
+
+ public void setNClob(int arg0, NClob arg1)
+ throws SQLException {
+ getPhysPs().setNClob(arg0, arg1);
+ }
+
+ public void setClob(int arg0, Reader arg1, long arg2)
+ throws SQLException {
+ getPhysPs().setClob(arg0, arg1, arg2);
+ }
+
+ public void setBlob(int arg0, InputStream arg1, long arg2)
+ throws SQLException {
+ getPhysPs().setBlob(arg0, arg1, arg2);
+ }
+
+ public void setNClob(int arg0, Reader arg1, long arg2)
+ throws SQLException {
+ getPhysPs().setNClob(arg0, arg1, arg2);
+ }
+
+ public void setSQLXML(int arg0, SQLXML arg1)
+ throws SQLException {
+ getPhysPs().setSQLXML(arg0, arg1);
+ }
+
+ public void setAsciiStream(int arg0, InputStream arg1, long arg2)
+ throws SQLException {
+ getPhysPs().setAsciiStream(arg0, arg1, arg2);
+ }
+
+ public void setBinaryStream(int arg0, InputStream arg1, long arg2)
+ throws SQLException {
+ getPhysPs().setBinaryStream(arg0, arg1, arg2);
+ }
+
+ public void setCharacterStream(int arg0, Reader arg1, long arg2)
+ throws SQLException {
+ getPhysPs().setCharacterStream(arg0, arg1, arg2);
+ }
+
+ public void setAsciiStream(int arg0, InputStream arg1)
+ throws SQLException {
+ getPhysPs().setAsciiStream(arg0, arg1);
+ }
+
+ public void setBinaryStream(int arg0, InputStream arg1)
+ throws SQLException {
+ getPhysPs().setBinaryStream(arg0, arg1);
+ }
+
+ public void setCharacterStream(int arg0, Reader arg1)
+ throws SQLException {
+ getPhysPs().setCharacterStream(arg0, arg1);
+ }
+
+ public void setNCharacterStream(int arg0, Reader arg1)
+ throws SQLException {
+ getPhysPs().setNCharacterStream(arg0, arg1);
+ }
+
+ public void setClob(int arg0, Reader arg1)
+ throws SQLException {
+ getPhysPs().setClob(arg0, arg1);
+ }
+
+ public void setBlob(int arg0, InputStream arg1)
+ throws SQLException {
+ getPhysPs().setBlob(arg0, arg1);
+ }
+
+ public void setNClob(int arg0, Reader arg1)
+ throws SQLException {
+ getPhysPs().setNClob(arg0, arg1);
+ }
+
+ public synchronized boolean isClosed()
+ throws SQLException {
+ // Note the extra synchronization.
+ boolean closed = isLogicalEntityClosed();
+ if (!closed) {
+ // Consult the underlying physical statement.
+ closed = getPhysPs().isClosed();
+ }
+ return closed;
+ }
+
+ public void setPoolable(boolean arg0)
+ throws SQLException {
+ getPhysPs().setPoolable(arg0);
+ }
+
+ public boolean isPoolable()
+ throws SQLException {
+ return getPhysPs().isPoolable();
+ }
+
+ ////////////////////////////////////////////////////////////////
+ //
// ADDED BY JDBC 4.2
//
////////////////////////////////////////////////////////////////
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalPreparedStatement42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalPreparedStatement42.java?rev=1482405&r1=1482404&r2=1482405&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalPreparedStatement42.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalPreparedStatement42.java Tue May 14 15:40:24 2013
@@ -29,8 +29,7 @@ import org.apache.derby.client.am.stmtca
/**
* JDBC 4.2 specific wrapper class for a Derby physical prepared statement.
*/
-public class LogicalPreparedStatement42
- extends LogicalPreparedStatement40
+public class LogicalPreparedStatement42 extends LogicalPreparedStatement
{
/**
* Creates a new logical prepared statement.
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/SQLExceptionFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/SQLExceptionFactory.java?rev=1482405&r1=1482404&r2=1482405&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/SQLExceptionFactory.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/SQLExceptionFactory.java Tue May 14 15:40:24 2013
@@ -18,32 +18,106 @@
limitations under the License.
*/
-
package org.apache.derby.client.am;
-import java.sql.SQLException;
import org.apache.derby.shared.common.reference.SQLState;
+import org.apache.derby.shared.common.error.ExceptionSeverity;
+
+import java.sql.SQLDataException;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.SQLIntegrityConstraintViolationException;
+import java.sql.SQLInvalidAuthorizationSpecException;
+import java.sql.SQLNonTransientConnectionException;
+import java.sql.SQLSyntaxErrorException;
+import java.sql.SQLTimeoutException;
+import java.sql.SQLTransactionRollbackException;
+
/**
- * class to create SQLException
+ * SQLException factory class to create jdbc 40 exception classes
*/
-public class SQLExceptionFactory {
-
- public static SQLException notImplemented (String feature) {
- SqlException sqlException = new SqlException (null,
- new ClientMessageId (SQLState.NOT_IMPLEMENTED), feature);
- return sqlException.getSQLException();
- }
+public class SQLExceptionFactory {
+ // Important DRDA SQL States, from DRDA v3 spec, Section 8.2
+ // We have to consider these as well as the standard SQLState classes
+ // when choosing the right exception subclass
+ private static final String DRDA_CONVERSATION_TERMINATED = "58009";
+ private static final String DRDA_COMMAND_NOT_SUPPORTED = "58014";
+ private static final String DRDA_OBJECT_NOT_SUPPORTED = "58015";
+ private static final String DRDA_PARAM_NOT_SUPPORTED = "58016";
+ private static final String DRDA_VALUE_NOT_SUPPORTED = "58017";
+ private static final String DRDA_SQLTYPE_NOT_SUPPORTED = "56084";
+ private static final String DRDA_CONVERSION_NOT_SUPPORTED = "57017";
+ private static final String DRDA_REPLY_MSG_NOT_SUPPORTED = "58018";
+
/**
- * creates SQLException initialized with all the params received from the
- * caller. This method will be overwritten to support jdbc version specific
- * exception class.
+ * creates jdbc4.0 SQLException and its subclass based on sql state
+ *
+ * @param message description of the
+ * @param sqlState
+ * @param errCode derby error code
*/
public SQLException getSQLException (String message, String sqlState,
- int errCode) {
- return new SQLException (message, sqlState, errCode);
- }
+ int errCode) {
+ SQLException ex = null;
+ if (sqlState == null) {
+ ex = new SQLException(message, sqlState, errCode);
+ } else if (sqlState.startsWith(SQLState.CONNECTIVITY_PREFIX)) {
+ //none of the sqlstate supported by derby belongs to
+ //TransientConnectionException. DERBY-3075
+ ex = new SQLNonTransientConnectionException(message, sqlState, errCode);
+ } else if (sqlState.startsWith(SQLState.SQL_DATA_PREFIX)) {
+ ex = new SQLDataException(message, sqlState, errCode);
+ } else if (sqlState.startsWith(SQLState.INTEGRITY_VIOLATION_PREFIX)) {
+ ex = new SQLIntegrityConstraintViolationException(message, sqlState,
+ errCode);
+ } else if (sqlState.startsWith(SQLState.AUTHORIZATION_SPEC_PREFIX)) {
+ ex = new SQLInvalidAuthorizationSpecException(message, sqlState,
+ errCode);
+ } else if (sqlState.startsWith(SQLState.TRANSACTION_PREFIX)) {
+ ex = new SQLTransactionRollbackException(message, sqlState,
+ errCode);
+ } else if (sqlState.startsWith(SQLState.LSE_COMPILATION_PREFIX)) {
+ ex = new SQLSyntaxErrorException(message, sqlState, errCode);
+ } else if (
+ sqlState.startsWith (SQLState.UNSUPPORTED_PREFIX) ||
+ sqlState.equals(DRDA_COMMAND_NOT_SUPPORTED) ||
+ sqlState.equals(DRDA_OBJECT_NOT_SUPPORTED) ||
+ sqlState.equals(DRDA_PARAM_NOT_SUPPORTED) ||
+ sqlState.equals(DRDA_VALUE_NOT_SUPPORTED) ||
+ sqlState.equals(DRDA_SQLTYPE_NOT_SUPPORTED) ||
+ sqlState.equals(DRDA_REPLY_MSG_NOT_SUPPORTED) ) {
+ ex = new SQLFeatureNotSupportedException(message, sqlState,
+ errCode);
+ } else if
+ (
+ sqlState.equals(SQLState.LANG_STATEMENT_CANCELLED_OR_TIMED_OUT.substring(0, 5)) ||
+ sqlState.equals(SQLState.LOGIN_TIMEOUT.substring(0, 5))
+ ) {
+ ex = new SQLTimeoutException(message, sqlState, errCode);
+ }
+ // If the sub-class cannot be determined based on the SQLState, use
+ // the severity instead.
+ else if (errCode >= ExceptionSeverity.SESSION_SEVERITY) {
+ ex = new SQLNonTransientConnectionException(
+ message, sqlState, errCode);
+ } else if (errCode >= ExceptionSeverity.TRANSACTION_SEVERITY) {
+ ex = new SQLTransactionRollbackException(
+ message, sqlState, errCode);
+ }
+ // If none of the above fit, return a plain SQLException.
+ else {
+ ex = new SQLException(message, sqlState, errCode);
+ }
+ return ex;
+ }
+
+ public static SQLFeatureNotSupportedException
+ notImplemented(String feature) {
+ SqlException sqlException = new SqlException(null,
+ new ClientMessageId(SQLState.NOT_IMPLEMENTED), feature);
+ return (SQLFeatureNotSupportedException) sqlException.getSQLException();
+ }
}
-
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlException.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlException.java?rev=1482405&r1=1482404&r2=1482405&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlException.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlException.java Tue May 14 15:40:24 2013
@@ -513,14 +513,6 @@ public class SqlException extends Except
return new SqlException(logWriter, getMessage(), getSQLState(), getErrorCode()); // client error
}
}
-
- /**
- * Sets the exceptionFactory to be used for creating SQLException
- * @param factory SQLExceptionFactory
- */
- public static void setExceptionFactory (SQLExceptionFactory factory) {
- exceptionFactory = factory;
- }
}
// An intermediate exception encapsulation to provide code-reuse
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl42.java?rev=1482405&r1=1482404&r2=1482405&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl42.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl42.java Tue May 14 15:40:24 2013
@@ -48,7 +48,7 @@ import org.apache.derby.client.am.stmtca
* Implements the ClientJDBCObjectFactory interface and returns the JDBC 4.2
* specific classes.
*/
-public class ClientJDBCObjectFactoryImpl42 extends ClientJDBCObjectFactoryImpl40
+public class ClientJDBCObjectFactoryImpl42 extends ClientJDBCObjectFactoryImpl
{
/**
* This method is overridden on JVM 8 to take advantage of long