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 rh...@apache.org on 2006/04/11 15:58:36 UTC
svn commit: r393221 [1/2] - in /db/derby/code/trunk/java:
engine/org/apache/derby/iapi/jdbc/ engine/org/apache/derby/impl/jdbc/
engine/org/apache/derby/jdbc/ engine/org/apache/derby/loc/
shared/org/apache/derby/shared/common/reference/ testing/org/apac...
Author: rhillegas
Date: Tue Apr 11 06:58:02 2006
New Revision: 393221
URL: http://svn.apache.org/viewcvs?rev=393221&view=rev
Log:
Commit Narayanan's patch for DERBY-940: embedded support for the JDBC4 wrapper api. Requires that you run with mustang build 78 or higher.
Added:
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement40.java (with props)
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterMetaData40.java (with props)
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData40.java (with props)
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement40.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/DataSourceTest.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/EmbeddedBrokeredConnectionWrapperTest.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ResultSetMetaDataTest.java (with props)
Modified:
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/build.xml
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection40.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData40.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement40.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java
db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java
db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource40.java
db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java
db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties
db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/CallableStatementTest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestResultSetMethods.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/SQLStateConstants.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement40.java?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement40.java Tue Apr 11 06:58:02 2006
@@ -28,6 +28,8 @@
import java.sql.RowId;
import java.sql.SQLException;
import java.sql.SQLXML;
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.impl.jdbc.Util;
public class BrokeredCallableStatement40 extends BrokeredCallableStatement30{
@@ -183,12 +185,39 @@
return getPreparedStatement().isPoolable();
}
- public java.lang.Object unwrap(java.lang.Class<?> interfaces) throws SQLException{
- return getPreparedStatement().unwrap(interfaces);
- }
-
- public boolean isWrapperFor(java.lang.Class<?> interfaces) throws java.sql.SQLException{
- return getPreparedStatement().isWrapperFor(interfaces);
+ /**
+ * 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 java.sql.SQLExption if no object if found that implements the
+ * interface
+ */
+ public <T> T unwrap(java.lang.Class<T> interfaces)
+ throws SQLException{
+ //Derby does not implement non-standard methods on
+ //JDBC objects
+ try {
+ return interfaces.cast(this);
+ } catch (ClassCastException cce) {
+ throw Util.generateCsSQLException(SQLState.UNABLE_TO_UNWRAP,
+ interfaces);
+ }
}
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java Tue Apr 11 06:58:02 2006
@@ -27,6 +27,7 @@
import java.sql.SQLXML;
import java.util.Properties;
import org.apache.derby.impl.jdbc.Util;
+import org.apache.derby.iapi.reference.SQLState;
public class BrokeredConnection40 extends BrokeredConnection30 {
@@ -82,6 +83,16 @@
throw Util.notImplemented();
}
+ /**
+ * returns an instance of JDBC4.0 speccific class BrokeredStatement40
+ * @param statementControl BrokeredStatementControl
+ * @return an instance of BrokeredStatement40
+ * throws java.sql.SQLException
+ */
+ public BrokeredStatement newBrokeredStatement
+ (BrokeredStatementControl statementControl) throws SQLException {
+ return new BrokeredStatement40(statementControl, getJDBCLevel());
+ }
public BrokeredPreparedStatement newBrokeredStatement(BrokeredStatementControl statementControl, String sql, Object generatedKeys) throws SQLException {
return new BrokeredPreparedStatement40(statementControl, getJDBCLevel(), sql, generatedKeys);
}
@@ -95,5 +106,39 @@
int getJDBCLevel() { return 4;}
+ /**
+ * 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 java.sql.SQLExption if no object if found that implements the
+ * interface
+ */
+ public <T> T unwrap(java.lang.Class<T> interfaces)
+ throws SQLException{
+ //Derby does not implement non-standard methods on
+ //JDBC objects
+ try {
+ return interfaces.cast(this);
+ } catch (ClassCastException cce) {
+ throw Util.generateCsSQLException(SQLState.UNABLE_TO_UNWRAP,
+ interfaces);
+ }
+ }
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement40.java?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement40.java Tue Apr 11 06:58:02 2006
@@ -27,7 +27,7 @@
import java.sql.SQLException;
import java.sql.SQLXML;
import org.apache.derby.impl.jdbc.Util;
-
+import org.apache.derby.iapi.reference.SQLState;
public class BrokeredPreparedStatement40 extends BrokeredPreparedStatement30{
@@ -79,12 +79,39 @@
throw Util.notImplemented();
}
- public java.lang.Object unwrap(java.lang.Class<?> interfaces) throws SQLException{
- throw Util.notImplemented();
- }
-
- public boolean isWrapperFor(java.lang.Class<?> interfaces) throws SQLException{
- throw Util.notImplemented();
+ /**
+ * 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 java.sql.SQLExption if no object if found that implements the
+ * interface
+ */
+ public <T> T unwrap(java.lang.Class<T> interfaces)
+ throws SQLException{
+ //Derby does not implement non-standard methods on
+ //JDBC objects
+ try {
+ return interfaces.cast(this);
+ } catch (ClassCastException cce) {
+ throw Util.generateCsSQLException(SQLState.UNABLE_TO_UNWRAP,
+ interfaces);
+ }
}
}
Added: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement40.java?rev=393221&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement40.java (added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement40.java Tue Apr 11 06:58:02 2006
@@ -0,0 +1,77 @@
+/*
+
+ Derby - Class org.apache.derby.iapi.jdbc.BrokeredStatement40
+
+ Copyright 2003, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.apache.derby.iapi.jdbc;
+
+import java.sql.SQLException;
+import org.apache.derby.impl.jdbc.Util;
+import org.apache.derby.iapi.reference.SQLState;
+
+
+public class BrokeredStatement40 extends BrokeredStatement {
+
+ /**
+ * calls the superclass constructor to pass the parameters
+ *
+ * @param control BrokeredStatementControl
+ * @param jdbcLevel int
+ * @throws java.sql.SQLException
+ *
+ */
+
+ BrokeredStatement40(BrokeredStatementControl control, int jdbcLevel)
+ throws SQLException {
+ super(control, jdbcLevel);
+ }
+
+ /**
+ * 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 java.sql.SQLExption if no object if found that implements the
+ * interface
+ */
+ public <T> T unwrap(java.lang.Class<T> interfaces)
+ throws SQLException {
+ //Derby does not implement non-standard methods on
+ //JDBC objects
+ try {
+ return interfaces.cast(this);
+ } catch (ClassCastException cce) {
+ throw Util.generateCsSQLException(SQLState.UNABLE_TO_UNWRAP,
+ interfaces);
+ }
+ }
+}
Propchange: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement40.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/build.xml
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/build.xml?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/build.xml (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/build.xml Tue Apr 11 06:58:02 2006
@@ -49,6 +49,7 @@
<exclude name="${derby.dir}/${cur.dir}/BrokeredCallableStatement30.java"/>
<exclude name="${derby.dir}/${cur.dir}/BrokeredCallableStatement40.java"/>
<exclude name="${derby.dir}/${cur.dir}/BrokeredStatement.java"/>
+ <exclude name="${derby.dir}/${cur.dir}/BrokeredStatement40.java"/>
<exclude name="${derby.dir}/${cur.dir}/JDBCBoot.java"/>
<exclude name="${derby.dir}/${cur.dir}/ResourceAdapter.java"/>
</javac>
@@ -134,6 +135,7 @@
<pathelement path="${java16compile.classpath}"/>
</classpath>
<include name="${derby.dir}/${cur.dir}/BrokeredConnection40.java"/>
+ <include name="${derby.dir}/${cur.dir}/BrokeredStatement40.java"/>
<include name="${derby.dir}/${cur.dir}/BrokeredPreparedStatement40.java"/>
<include name="${derby.dir}/${cur.dir}/BrokeredCallableStatement40.java"/>
</javac>
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java Tue Apr 11 06:58:02 2006
@@ -29,6 +29,8 @@
import java.sql.SQLException;
import java.sql.SQLXML;
+import org.apache.derby.iapi.reference.SQLState;
+
public class EmbedCallableStatement40 extends EmbedCallableStatement30 {
@@ -177,5 +179,38 @@
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException{
throw Util.notImplemented ("setSQLXML (int, 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 {
+ 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(java.lang.Class<T> interfaces)
+ throws SQLException{
+ try {
+ return interfaces.cast(this);
+ } catch (ClassCastException cce) {
+ throw newSQLException(SQLState.UNABLE_TO_UNWRAP,interfaces);
+ }
+ }
+
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection40.java?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection40.java Tue Apr 11 06:58:02 2006
@@ -29,9 +29,8 @@
import java.sql.SQLException;
import java.sql.SQLXML;
import java.util.Properties;
-
-import org.apache.derby.shared.common.reference.SQLState;
import org.apache.derby.jdbc.InternalDriver;
+import org.apache.derby.iapi.reference.SQLState;
public class EmbedConnection40 extends EmbedConnection30 {
@@ -132,5 +131,41 @@
public java.util.Map<String,Class<?>> getTypeMap() {
throw new java.lang.UnsupportedOperationException();
+ }
+
+ /**
+ * 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 java.sql.SQLExption if no object if found that implements the
+ * interface
+ */
+ public <T> T unwrap(java.lang.Class<T> interfaces)
+ throws SQLException{
+ //Derby does not implement non-standard methods on
+ //JDBC objects
+ //hence return this if this class implements the interface
+ //or throw an SQLException
+ try {
+ return interfaces.cast(this);
+ } catch (ClassCastException cce) {
+ throw newSQLException(SQLState.UNABLE_TO_UNWRAP,interfaces);
+ }
}
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData40.java?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData40.java Tue Apr 11 06:58:02 2006
@@ -26,6 +26,7 @@
import java.sql.SQLException;
import java.sql.PreparedStatement;
import org.apache.derby.impl.jdbc.Util;
+import org.apache.derby.iapi.reference.SQLState;
public class EmbedDatabaseMetaData40 extends EmbedDatabaseMetaData {
@@ -101,6 +102,42 @@
throws SQLException
{
return getSimpleQuery("getFunctionParameters");
+ }
+
+ /**
+ * 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 java.sql.SQLExption if no object if found that implements the
+ * interface
+ */
+ public <T> T unwrap(java.lang.Class<T> interfaces)
+ throws SQLException{
+ //Derby does not implement non-standard methods on
+ //JDBC objects
+ //hence return this if this class implements the interface
+ //or throw an SQLException
+ try {
+ return interfaces.cast(this);
+ } catch (ClassCastException cce) {
+ throw newSQLException(SQLState.UNABLE_TO_UNWRAP,interfaces);
+ }
}
}
Added: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterMetaData40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterMetaData40.java?rev=393221&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterMetaData40.java (added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterMetaData40.java Tue Apr 11 06:58:02 2006
@@ -0,0 +1,77 @@
+/*
+
+ Derby - Class org.apache.derby.impl.jdbc.EmbedParametertMetaData40
+
+ Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+package org.apache.derby.impl.jdbc;
+
+import java.sql.SQLException;
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.sql.ParameterValueSet;
+import org.apache.derby.iapi.types.DataTypeDescriptor;
+
+public class EmbedParameterMetaData40 extends EmbedParameterMetaData30 {
+
+ /**
+ * Calls the superclass constructors with the parameters passed
+ *
+ * @param pvs ParameterValueSet pvs
+ * @param types DataTypeDescriptor
+ */
+ protected EmbedParameterMetaData40(ParameterValueSet pvs,
+ DataTypeDescriptor[] types) {
+ super(pvs,types);
+ }
+
+ /**
+ * 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 java.sql.SQLExption if no object if found that implements the
+ * interface
+ */
+ public <T> T unwrap(java.lang.Class<T> interfaces)
+ throws SQLException{
+ //Derby does not implement non-standard methods on
+ //JDBC objects
+ //hence return this if this class implements the interface
+ //or throw an SQLException
+ try {
+ return interfaces.cast(this);
+ } catch (ClassCastException cce) {
+ throw Util.generateCsSQLException(SQLState.UNABLE_TO_UNWRAP,
+ interfaces);
+ }
+ }
+}
Propchange: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterMetaData40.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java?rev=393221&r1=393220&r2=393221&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 Apr 11 06:58:02 2006
@@ -1393,7 +1393,7 @@
//
protected EmbedResultSetMetaData newEmbedResultSetMetaData(ResultDescription resultDesc) {
- return new EmbedResultSetMetaData(resultDesc.getColumnInfo());
+ return factory.newEmbedResultSetMetaData(resultDesc.getColumnInfo());
}
public String toString() {
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement40.java?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement40.java Tue Apr 11 06:58:02 2006
@@ -63,5 +63,37 @@
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException{
throw Util.notImplemented();
}
+
+ /**
+ * 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 java.sql.SQLExption if no object if found that implements the
+ * interface
+ */
+ public <T> T unwrap(java.lang.Class<T> interfaces)
+ throws SQLException{
+ try {
+ return interfaces.cast(this);
+ } catch (ClassCastException cce) {
+ throw newSQLException(SQLState.UNABLE_TO_UNWRAP,interfaces);
+ }
+ }
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java Tue Apr 11 06:58:02 2006
@@ -192,7 +192,7 @@
* as a stream for a row. Created on-demand by a getXXXStream call.
*/
private boolean[] streamUsedFlags;
-
+
/**
* This class provides the glue between the Cloudscape
* resultset and the JDBC resultset, mapping calls-to-calls.
@@ -214,6 +214,7 @@
: (long)stmt.getQueryTimeout() * 1000L;
this.isAtomic = isAtomic;
+
//If the Statement object has CONCUR_READ_ONLY set on it then the concurrency on the ResultSet object will be CONCUR_READ_ONLY also.
//But, if the Statement object has CONCUR_UPDATABLE set on it, then the concurrency on the ResultSet object can be
@@ -4022,7 +4023,7 @@
// that want to stay within their subimplementation.
//
protected EmbedResultSetMetaData newEmbedResultSetMetaData(ResultDescription resultDesc) {
- return new EmbedResultSetMetaData(resultDesc.getColumnInfo());
+ return factory.newEmbedResultSetMetaData(resultDesc.getColumnInfo());
}
/**
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java Tue Apr 11 06:58:02 2006
@@ -27,6 +27,8 @@
import org.apache.derby.iapi.sql.ResultSet;
import java.sql.Statement;
+import org.apache.derby.iapi.reference.SQLState;
+
/**
* Implementation of JDBC 4 specific ResultSet methods.
*/
@@ -98,6 +100,42 @@
public void updateSQLXML(String columnName, SQLXML xmlObject) throws SQLException {
throw Util.notImplemented();
+ }
+
+ /**
+ * 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 java.sql.SQLExption if no object if found that implements the
+ * interface
+ */
+ public <T> T unwrap(java.lang.Class<T> interfaces)
+ throws SQLException{
+ //Derby does not implement non-standard methods on
+ //JDBC objects
+ //hence return this if this class implements the interface
+ //or throw an SQLException
+ try {
+ return interfaces.cast(this);
+ } catch (ClassCastException cce) {
+ throw newSQLException(SQLState.UNABLE_TO_UNWRAP,interfaces);
+ }
}
}
Added: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData40.java?rev=393221&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData40.java (added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData40.java Tue Apr 11 06:58:02 2006
@@ -0,0 +1,69 @@
+/*
+
+ Derby - Class org.apache.derby.impl.jdbc.EmbedResultSetMetaData40
+
+ Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.apache.derby.impl.jdbc;
+
+import java.sql.SQLException;
+
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.sql.ResultColumnDescriptor;
+
+public class EmbedResultSetMetaData40 extends EmbedResultSetMetaData {
+
+ public EmbedResultSetMetaData40(ResultColumnDescriptor[] columnInfo) {
+ super(columnInfo);
+ }
+
+ /**
+ * 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 java.sql.SQLExption if no object if found that implements the
+ * interface
+ */
+ public <T> T unwrap(java.lang.Class<T> interfaces)
+ throws SQLException{
+ //Derby does not implement non-standard methods on
+ //JDBC objects
+ //hence return this if this class implements the interface
+ //or throw an SQLException
+ try {
+ return interfaces.cast(this);
+ } catch (ClassCastException cce) {
+ throw Util.generateCsSQLException(SQLState.UNABLE_TO_UNWRAP,
+ interfaces);
+ }
+ }
+}
Propchange: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData40.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement40.java?rev=393221&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement40.java (added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement40.java Tue Apr 11 06:58:02 2006
@@ -0,0 +1,78 @@
+/*
+
+ Derby - Class org.apache.derby.impl.jdbc.EmbedStatement40
+
+ Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+package org.apache.derby.impl.jdbc;
+
+import java.sql.SQLException;
+import org.apache.derby.iapi.reference.SQLState;
+
+public class EmbedStatement40 extends EmbedStatement {
+
+ /**
+ * calls superclass contructor with the parameter passed
+ *
+ * @param connection EmbedConnection object associated with this
+ * statement
+ * @param forMetaData boolean
+ * @param resultSetType int
+ * @param resultSetConcurrency int
+ * @param resultSetHoldability int
+ *
+ */
+ public EmbedStatement40 (EmbedConnection connection, boolean forMetaData,
+ int resultSetType, int resultSetConcurrency,
+ int resultSetHoldability) {
+ super(connection,forMetaData,resultSetType,resultSetConcurrency,
+ resultSetHoldability);
+ }
+
+ /**
+ * 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 java.sql.SQLExption if no object if found that implements the
+ * interface
+ */
+ public <T> T unwrap(java.lang.Class<T> interfaces)
+ throws SQLException{
+ try {
+ return interfaces.cast(this);
+ } catch (ClassCastException cce) {
+ throw newSQLException(SQLState.UNABLE_TO_UNWRAP,interfaces);
+ }
+ }
+
+}
Propchange: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement40.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java?rev=393221&r1=393220&r2=393221&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 Apr 11 06:58:02 2006
@@ -37,13 +37,15 @@
import org.apache.derby.impl.jdbc.EmbedResultSet40;
import org.apache.derby.impl.jdbc.EmbedDatabaseMetaData40;
import org.apache.derby.impl.jdbc.SQLExceptionFactory40;
+import org.apache.derby.impl.jdbc.EmbedStatement40;
+import org.apache.derby.impl.jdbc.EmbedResultSetMetaData40;
import org.apache.derby.impl.jdbc.Util;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.util.Properties;
-
+import org.apache.derby.iapi.sql.ResultColumnDescriptor;
public class Driver40 extends Driver30 {
@@ -62,6 +64,27 @@
return new EmbedConnection40(this, url, info);
}
+ /**
+ * returns a new EmbedStatement
+ * @param conn the EmbedConnection class associated with
+ * this statement object
+ * @param forMetadata boolean
+ * @param resultSetType int
+ * @param resultSetConcurrency int
+ * @param resultSetHoldability int
+ * @return Statement a new java.sql.Statement implementation
+ *
+ */
+ public java.sql.Statement newEmbedStatement(
+ EmbedConnection conn,
+ boolean forMetaData,
+ int resultSetType,
+ int resultSetConcurrency,
+ int resultSetHoldability)
+ {
+ return new EmbedStatement40(conn, forMetaData, resultSetType, resultSetConcurrency,
+ resultSetHoldability);
+ }
public PreparedStatement
newEmbedPreparedStatement(
@@ -129,4 +152,16 @@
throws SQLException {
return new EmbedDatabaseMetaData40(conn,dbname);
}
+
+ /**
+ * Returns a new java.sql.ResultSetMetaData for this implementation
+ *
+ * @param columnInfo a ResultColumnDescriptor that stores information
+ * about the columns in a ResultSet
+ * @return ResultSetMetaData
+ */
+ public EmbedResultSetMetaData40 newEmbedResultSetMetaData
+ (ResultColumnDescriptor[] columnInfo) {
+ return new EmbedResultSetMetaData40(columnInfo);
+ }
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource40.java?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource40.java Tue Apr 11 06:58:02 2006
@@ -26,6 +26,8 @@
import org.apache.derby.impl.jdbc.Util;
import java.sql.SQLException;
+import org.apache.derby.iapi.reference.SQLState;
+
public class EmbeddedDataSource40 extends EmbeddedDataSource {
public EmbeddedDataSource40() {
@@ -50,4 +52,41 @@
throws SQLException {
return QueryObjectFactory.createDefaultQueryObject (ifc, this);
}
+
+ /**
+ * 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 java.sql.SQLExption if no object if found that implements the
+ * interface
+ */
+ public <T> T unwrap(java.lang.Class<T> interfaces)
+ throws SQLException{
+ //Derby does not implement non-standard methods on
+ //JDBC objects
+ //hence return this if this class implements the interface
+ //or throw an SQLException
+ try {
+ return interfaces.cast(this);
+ } catch (ClassCastException cce) {
+ throw Util.generateCsSQLException(SQLState.UNABLE_TO_UNWRAP,
+ interfaces);
+ }
+ }
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java Tue Apr 11 06:58:02 2006
@@ -39,6 +39,7 @@
import org.apache.derby.iapi.sql.ResultSet;
import org.apache.derby.iapi.jdbc.AuthenticationService;
+import org.apache.derby.iapi.sql.ResultColumnDescriptor;
import org.apache.derby.impl.jdbc.*;
@@ -514,6 +515,17 @@
*/
public abstract EmbedResultSet
newEmbedResultSet(EmbedConnection conn, ResultSet results, boolean forMetaData, EmbedStatement statement, boolean isAtomic) throws SQLException;
+
+ /**
+ * Returns a new java.sql.ResultSetMetaData for this implementation
+ *
+ * @param columnInfo a ResultColumnDescriptor that stores information
+ * about the columns in a ResultSet
+ */
+ public EmbedResultSetMetaData newEmbedResultSetMetaData
+ (ResultColumnDescriptor[] columnInfo) {
+ return new EmbedResultSetMetaData(columnInfo);
+ }
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties Tue Apr 11 06:58:02 2006
@@ -1139,6 +1139,7 @@
XJ085.S=Stream has already been read and end-of-file reached and cannot be re-used.
XJ086.S=This method cannot be invoked unless the cursor is positioned on the insert row.
XJ087.S=Invalid java.sql.Types type {0}.
+
XJ088.S=Invalid operation: wasNull() called with no data retrieved.
XJ089.S=Invalid method call: parameter 1 is an integer OUT parameter returned by the stored procedure, use getInt call.
XJ090.S=Invalid parameter: calendar is null.
@@ -1161,8 +1162,8 @@
XJ111.S=Foreign table name can not be null
XJ112.S=Security exception encountered, see next exception for details.
XJ113.S=Unable to open file {0} : {1}
+XJ120.S=Unable to unwrap for ''{0}''
-#0A - feature not implemented
0A000.S=Feature not implemented: {0}.
0A000.S.1=JDBC method is not yet implemented.
0A000.S.2=JDBC method {0} is not supported by the server. Please upgrade the server.
Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java (original)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java Tue Apr 11 06:58:02 2006
@@ -1464,6 +1464,8 @@
String UPDATABLE_RESULTSET_API_DISALLOWED = "XJ083.U";
String COLUMN_NOT_FROM_BASE_TABLE = "XJ084.U";
String NOT_POSITIONED_ON_INSERT_ROW = "XJ086.S";
+
+
String WASNULL_INVALID = "XJ088.S";
String INVALID_PARAM_USE_GETINT = "XJ089.S";
String CALENDAR_IS_NULL = "XJ090.S";
@@ -1486,6 +1488,8 @@
String FOREIGN_TABLE_NAME_IS_NULL = "XJ111.S";
String SECURITY_EXCEPTION_ENCOUNTERED = "XJ112.S";
String UNABLE_TO_OPEN_FILE = "XJ113.S";
+ //wrapper related
+ String UNABLE_TO_UNWRAP = "XJ120.S";
//following are session severity.
String DATABASE_NOT_FOUND = "XJ004.C";
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude Tue Apr 11 06:58:02 2006
@@ -26,6 +26,12 @@
jdbc4/TestDbMetaData.java
jdbc4/TestJDBC40Exception.java
jdbcapi/SURTest.junit
+#temporarily exclude until wrapper support for the client side is also added
+#begin
+jdbc4/DataSourceTest.junit
+jdbc4/ResultSetMetaDataTest.junit
+jdbc4/EmbeddedBrokeredConnectionWrapperTest.junit
+#end
#temporarily disable checkDataSourceTests with client
#failing (hanging?) on jdk 1.5/jdk 1.6
jdbcapi/checkDataSource.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall Tue Apr 11 06:58:02 2006
@@ -7,3 +7,6 @@
jdbc4/CallableStatementTest.junit
jdbc4/RowIdNotImplementedTest.junit
jdbc4/StatementTest.junit
+jdbc4/DataSourceTest.junit
+jdbc4/ResultSetMetaDataTest.junit
+jdbc4/EmbeddedBrokeredConnectionWrapperTest.junit
\ No newline at end of file
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/CallableStatementTest.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/CallableStatementTest.java?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/CallableStatementTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/CallableStatementTest.java Tue Apr 11 06:58:02 2006
@@ -23,8 +23,11 @@
import junit.framework.*;
import org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase;
+import org.apache.derbyTesting.functionTests.util.SQLStateConstants;
import java.sql.*;
+import java.lang.reflect.Method;
+import java.util.Vector;
/**
* Tests of the <code>java.sql.CallableStatement</code> JDBC40 API.
@@ -261,6 +264,76 @@
"should not be implemented");
} catch (SQLFeatureNotSupportedException sfnse) {
// We are fine, do nothing.
+ }
+ }
+
+ /**
+ *
+ * Tests the wrapper methods isWrapperFor and unwrap. Test
+ * for the case when isWrapperFor returns true and we call unwrap
+ * The test is right now being run in the embedded case only
+ *
+ */
+ public void testisWrapperReturnsTrue() throws SQLException {
+ //wrapper support is currently provided
+ //only for embedded side so return if
+ //running in DerbyNetClient framework
+ if(usingDerbyNetClient())
+ return;
+
+ Class<CallableStatement> wrap_class = CallableStatement.class;
+
+ //The if should return true enabling us to call the unwrap method
+ //without throwing an exception
+ if(cStmt.isWrapperFor(wrap_class)) {
+ try {
+ CallableStatement stmt1 =
+ (CallableStatement)cStmt.unwrap(wrap_class);
+ }
+ catch(SQLException sqle) {
+ fail("Unwrap wrongly throws a SQLException");
+ }
+ } else {
+ fail("isWrapperFor wrongly returns false");
+ }
+ }
+
+ /**
+ *
+ * Tests the wrapper methods isWrapperFor and unwrap. Test
+ * for the case when isWrapperFor returns false and we call unwrap
+ * The test is right now being run in the embedded case only
+ *
+ */
+ public void testisWrapperReturnsFalse() throws SQLException {
+ //wrapper support is currently provided
+ //only for embedded side so return if
+ //running in DerbyNetClient framework
+ if(usingDerbyNetClient())
+ return;
+
+ //test for the case when isWrapper returns false
+ //using some class that will return false when
+ //passed to isWrapperFor
+ Class<ResultSet> wrap_class = ResultSet.class;
+
+ //returning false is the correct behaviour in this case
+ //Generate a message if it returns true
+ if(cStmt.isWrapperFor(wrap_class)) {
+ fail("isWrapperFor wrongly returns true");
+ } else {
+ try {
+ ResultSet rs1 = (ResultSet)
+ cStmt.unwrap(wrap_class);
+ fail("unwrap does not throw the expected " +
+ "exception");
+ } catch (SQLException sqle) {
+ //calling unwrap in this case throws an SQLException
+ //check that this SQLException has the correct SQLState
+ if(!SQLStateConstants.UNABLE_TO_UNWRAP.equals(sqle.getSQLState())) {
+ throw sqle;
+ }
+ }
}
}
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/DataSourceTest.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/DataSourceTest.java?rev=393221&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/DataSourceTest.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/DataSourceTest.java Tue Apr 11 06:58:02 2006
@@ -0,0 +1,129 @@
+/*
+
+ Derby - Class org.apache.derbyTesting.functionTests.tests.jdbc4.DataSourceTest
+
+ Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.functionTests.tests.jdbc4;
+
+import junit.framework.*;
+
+import org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase;
+import org.apache.derbyTesting.functionTests.util.SQLStateConstants;
+
+import java.sql.*;
+import javax.sql.*;
+
+/**
+ * Tests of the <code>javax.sql.DataSource</code> JDBC40 API.
+ */
+
+public class DataSourceTest extends BaseJDBCTestCase {
+
+ //Default DataSource that will be used by the tests
+ private DataSource ds = null;
+
+ /**
+ *
+ * Create a test with the given name.
+ *
+ * @param name name of the test.
+ *
+ */
+ public DataSourceTest(String name) {
+ super(name);
+ }
+
+ /**
+ * Create a default DataSource
+ */
+ public void setUp() {
+ ds = getDataSource();
+ }
+
+ /**
+ *
+ * Initialize the ds to null once the tests that need to be run have been
+ * run
+ */
+ public void tearDown() {
+ ds = null;
+ }
+
+ /**
+ *
+ * Tests the wrapper methods isWrapperFor and unwrap. Test
+ * for the case when isWrapperFor returns true and we call unwrap
+ * The test is right now being run in the embedded case only
+ *
+ */
+ public void testisWrapperReturnsTrue() throws SQLException {
+ Class<DataSource> wrap_class = DataSource.class;
+
+ //The if should return true enabling us to call the unwrap method
+ //without throwing an exception
+ if(ds.isWrapperFor(wrap_class)) {
+ try {
+ DataSource stmt1 =
+ (DataSource)ds.unwrap(wrap_class);
+ }
+ catch(SQLException sqle) {
+ fail("Unwrap wrongly throws a SQLException");
+ }
+ } else {
+ fail("isWrapperFor wrongly returns false");
+ }
+ }
+
+ /**
+ *
+ * Tests the wrapper methods isWrapperFor and unwrap. Test
+ * for the case when isWrapperFor returns false and we call unwrap
+ * The test is right now being run in the embedded case only
+ *
+ */
+ public void testisWrapperReturnsFalse() throws SQLException {
+ Class<ResultSet> wrap_class = ResultSet.class;
+
+ //returning false is the correct behaviour in this case
+ //Generate a message if it returns true
+ if(ds.isWrapperFor(wrap_class)) {
+ fail("isWrapperFor wrongly returns true");
+ } else {
+ try {
+ ResultSet rs1 = (ResultSet)
+ ds.unwrap(wrap_class);
+ fail("unwrap does not throw the expected " +
+ "exception");
+ } catch (SQLException sqle) {
+ //calling unwrap in this case throws an SQLException
+ //check that this SQLException has the correct SQLState
+ if(!SQLStateConstants.UNABLE_TO_UNWRAP.equals(sqle.getSQLState())) {
+ throw sqle;
+ }
+ }
+ }
+ }
+
+ /**
+ * Return suite with all tests of the class.
+ */
+ public static Test suite() {
+ return (new TestSuite(DataSourceTest.class,
+ "DataSourceTest suite"));
+ }
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/DataSourceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/EmbeddedBrokeredConnectionWrapperTest.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/EmbeddedBrokeredConnectionWrapperTest.java?rev=393221&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/EmbeddedBrokeredConnectionWrapperTest.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/EmbeddedBrokeredConnectionWrapperTest.java Tue Apr 11 06:58:02 2006
@@ -0,0 +1,135 @@
+/*
+
+ Derby - Class org.apache.derbyTesting.functionTests.tests.jdbc4.EmbeddedBrokeredConnectionWrapperTest
+
+ Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.apache.derbyTesting.functionTests.tests.jdbc4;
+
+import java.sql.*;
+import javax.sql.*;
+import junit.framework.*;
+import org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase;
+import org.apache.derbyTesting.functionTests.util.SQLStateConstants;
+
+public class EmbeddedBrokeredConnectionWrapperTest extends BaseJDBCTestCase {
+ //Classes that will be used in this test
+ private PooledConnection pConn = null;
+ private Connection conn = null;
+
+ /**
+ *
+ * Create a test with the given name.
+ *
+ * @param name name of the test.
+ *
+ */
+ public EmbeddedBrokeredConnectionWrapperTest(String name) {
+ super(name);
+ }
+
+ /**
+ * Create the classes that will be used in the
+ * test
+ *
+ */
+ public void setUp() throws SQLException {
+ //The ConnectionPoolDataSource object
+ //used to get a PooledConnection object
+ ConnectionPoolDataSource cpDataSource = getConnectionPoolDataSource();
+ pConn = cpDataSource.getPooledConnection();
+ //doing a getConnection() returns a Connection object
+ //that internally contains a BrokeredConnection40 object
+ //this is then used to check the wrapper object
+ conn = pConn.getConnection();
+ }
+
+ /**
+ * uninitialize pConn and conn
+ */
+ public void tearDown() throws SQLException {
+ if(conn != null && !conn.isClosed()) {
+ conn.rollback();
+ conn.close();
+ }
+ if(pConn != null) {
+ pConn.close();
+ }
+ }
+
+ /**
+ *
+ * Tests the wrapper methods isWrapperFor and unwrap. Test
+ * for the case when isWrapperFor returns true and we call unwrap
+ * The test is right now being run in the embedded case only
+ *
+ */
+ public void testisWrapperReturnsTrue() throws SQLException {
+ Class<Connection> wrap_class = Connection.class;
+
+ //The if should return true enabling us to call the unwrap method
+ //without throwing an exception
+ if(conn.isWrapperFor(wrap_class)) {
+ try {
+ Connection conn1 =
+ (Connection)conn.unwrap(wrap_class);
+ }
+ catch(SQLException sqle) {
+ fail("Unwrap wrongly throws a SQLException");
+ }
+ } else {
+ fail("isWrapperFor wrongly returns false");
+ }
+ }
+
+ /**
+ *
+ * Tests the wrapper methods isWrapperFor and unwrap. Test
+ * for the case when isWrapperFor returns false and we call unwrap
+ * The test is right now being run in the embedded case only
+ *
+ */
+ public void testisWrapperReturnsFalse() throws SQLException {
+ Class<ResultSet> wrap_class = ResultSet.class;
+
+ //returning false is the correct behaviour in this case
+ //Generate a message if it returns true
+ if(conn.isWrapperFor(wrap_class)) {
+ fail("isWrapperFor wrongly returns true");
+ } else {
+ try {
+ ResultSet rs1 = (ResultSet)
+ conn.unwrap(wrap_class);
+ fail("unwrap does not throw the expected " +
+ "exception");
+ } catch (SQLException sqle) {
+ //calling unwrap in this case throws an SQLException
+ //check that this SQLException has the correct SQLState
+ if(!SQLStateConstants.UNABLE_TO_UNWRAP.equals(sqle.getSQLState())) {
+ throw sqle;
+ }
+ }
+ }
+ }
+
+ /**
+ * Return suite with all tests of the class.
+ */
+ public static Test suite() {
+ return (new TestSuite(EmbeddedBrokeredConnectionWrapperTest.class,
+ "EmbeddedBrokeredConnectionWrapperTest suite"));
+ }
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/EmbeddedBrokeredConnectionWrapperTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ResultSetMetaDataTest.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ResultSetMetaDataTest.java?rev=393221&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ResultSetMetaDataTest.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ResultSetMetaDataTest.java Tue Apr 11 06:58:02 2006
@@ -0,0 +1,138 @@
+/*
+
+ Derby - Class org.apache.derbyTesting.functionTests.tests.jdbc4.ResultSetMetaDataTest
+
+ Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.apache.derbyTesting.functionTests.tests.jdbc4;
+
+import junit.framework.*;
+
+import org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase;
+import org.apache.derbyTesting.functionTests.util.SQLStateConstants;
+
+import java.sql.*;
+import javax.sql.*;
+
+
+public class ResultSetMetaDataTest extends BaseJDBCTestCase {
+ //classes that will be used for the test
+ private Connection conn =null;
+ private PreparedStatement ps =null;
+ private ResultSet rs =null;
+ //The ResultSetMetaData object that will be used throughout the test
+ private ResultSetMetaData rsmd =null;
+
+ /**
+ *
+ * Create a test with the given name.
+ *
+ * @param name name of the test.
+ *
+ */
+ public ResultSetMetaDataTest(String name) {
+ super(name);
+ }
+
+ /**
+ * Create a default DataSource
+ */
+ public void setUp() throws SQLException {
+ conn = getConnection();
+ ps = conn.prepareStatement("select count(*) from sys.systables");
+ rs = ps.executeQuery();
+ rsmd = rs.getMetaData();
+ }
+
+ /**
+ *
+ * Initialize the ds to null once the tests that need to be run have been
+ * run
+ */
+ public void tearDown() throws SQLException {
+ if(rs != null && !rs.isClosed())
+ rs.close();
+ if(ps != null && !ps.isClosed())
+ ps.close();
+ if(conn != null && !conn.isClosed()) {
+ conn.rollback();
+ conn.close();
+ }
+ }
+
+ /**
+ *
+ * Tests the wrapper methods isWrapperFor and unwrap. Test
+ * for the case when isWrapperFor returns true and we call unwrap
+ * The test is right now being run in the embedded case only
+ *
+ */
+ public void testisWrapperReturnsTrue() throws SQLException {
+ Class<ResultSetMetaData> wrap_class = ResultSetMetaData.class;
+
+ //The if should return true enabling us to call the unwrap method
+ //without throwing an exception
+ if(rsmd.isWrapperFor(wrap_class)) {
+ try {
+ ResultSetMetaData rsmd1 =
+ (ResultSetMetaData)rsmd.unwrap(wrap_class);
+ }
+ catch(SQLException sqle) {
+ fail("Unwrap wrongly throws a SQLException");
+ }
+ } else {
+ fail("isWrapperFor wrongly returns false");
+ }
+ }
+
+ /**
+ *
+ * Tests the wrapper methods isWrapperFor and unwrap. Test
+ * for the case when isWrapperFor returns false and we call unwrap
+ * The test is right now being run in the embedded case only
+ *
+ */
+ public void testisWrapperReturnsFalse() throws SQLException {
+ Class<ResultSet> wrap_class = ResultSet.class;
+
+ //returning false is the correct behaviour in this case
+ //Generate a message if it returns true
+ if(rsmd.isWrapperFor(wrap_class)) {
+ fail("isWrapperFor wrongly returns true");
+ } else {
+ try {
+ ResultSet rs1 = (ResultSet)
+ rsmd.unwrap(wrap_class);
+ fail("unwrap does not throw the expected " +
+ "exception");
+ } catch (SQLException sqle) {
+ //calling unwrap in this case throws an SQLException
+ //check that this SQLException has the correct SQLState
+ if(!SQLStateConstants.UNABLE_TO_UNWRAP.equals(sqle.getSQLState())) {
+ throw sqle;
+ }
+ }
+ }
+ }
+
+ /**
+ * Return suite with all tests of the class.
+ */
+ public static Test suite() {
+ return (new TestSuite(ResultSetMetaDataTest.class,
+ "ResultSetMetaDataTest suite"));
+ }
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ResultSetMetaDataTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTest.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTest.java?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTest.java Tue Apr 11 06:58:02 2006
@@ -233,6 +233,76 @@
}
/**
+ *
+ * Tests the wrapper methods isWrapperFor and unwrap. Test
+ * for the case when isWrapperFor returns true and we call unwrap
+ * The test is right now being run in the embedded case only
+ *
+ */
+ public void testisWrapperReturnsTrue() throws SQLException {
+ //wrapper support is currently provided
+ //only for embedded side so return if
+ //running in DerbyNetClient framework
+ if(usingDerbyNetClient())
+ return;
+
+ Class<Statement> wrap_class = Statement.class;
+
+ //The if should return true enabling us to call the unwrap method
+ //without throwing an exception
+ if(stmt.isWrapperFor(wrap_class)) {
+ try {
+ Statement stmt1 =
+ (Statement)stmt.unwrap(wrap_class);
+ }
+ catch(SQLException sqle) {
+ fail("Unwrap wrongly throws a SQLException");
+ }
+ } else {
+ fail("isWrapperFor wrongly returns false");
+ }
+ }
+
+ /**
+ *
+ * Tests the wrapper methods isWrapperFor and unwrap. Test
+ * for the case when isWrapperFor returns false and we call unwrap
+ * The test is right now being run in the embedded case only.
+ *
+ */
+ public void testisWrapperReturnsFalse() throws SQLException {
+ //wrapper support is currently provided
+ //only for embedded side so return if
+ //running in DerbyNetClient framework
+ if(usingDerbyNetClient())
+ return;
+
+ //test for the case when isWrapper returns false
+ //using some class that will return false when
+ //passed to isWrapperFor
+ Class<ResultSet> wrap_class = ResultSet.class;
+
+ //returning false is the correct behaviour in this case
+ //Generate a message if it returns true
+ if(stmt.isWrapperFor(wrap_class)) {
+ fail("isWrapperFor wrongly returns true");
+ } else {
+ try {
+ ResultSet rs1 = (ResultSet)
+ stmt.unwrap(wrap_class);
+ fail("unwrap does not throw the expected " +
+ "exception");
+ } catch (SQLException sqle) {
+ //calling unwrap in this case throws an SQLException
+ //check that this SQLException has the correct SQLState
+ if(!SQLStateConstants.UNABLE_TO_UNWRAP.equals(sqle.getSQLState())) {
+ throw sqle;
+ }
+ }
+ }
+ }
+
+ /**
* Create test suite for StatementTest.
*/
public static Test suite() {
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java Tue Apr 11 06:58:02 2006
@@ -29,6 +29,7 @@
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Connection;
+import java.sql.CallableStatement;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.NClob;
@@ -39,6 +40,7 @@
import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.tools.ij;
import org.apache.derby.shared.common.reference.SQLState;
+import org.apache.derbyTesting.functionTests.util.SQLStateConstants;
/**
* This class is used to test the implementations of the JDBC 4.0 methods
@@ -374,6 +376,60 @@
}
}
+ /**
+ * Tests the wrapper methods isWrapperFor and unwrap. There are two cases
+ * to be tested
+ * Case 1: isWrapperFor returns true and we call unwrap
+ * Case 2: isWrapperFor returns false and we call unwrap
+ */
+ void t_wrapper() {
+ //test for the case when isWrapper returns true
+ //Begin test for Case1:
+ Class<Connection> wrap_class = Connection.class;
+
+ //The if method succeeds enabling us to call the unwrap method without
+ //throwing an exception
+ try {
+ if(conn.isWrapperFor(wrap_class)) {
+ Connection conn1 =
+ (Connection)conn.unwrap(wrap_class);
+ }
+ else {
+ System.out.println("isWrapperFor wrongly returns false");
+ }
+ }
+ catch(SQLException sqle) {
+ sqle.printStackTrace();
+ }
+
+ //Begin test for case2
+ //test for the case when isWrapper returns false
+ //using some class that will return false when
+ //passed to isWrapperFor
+ Class<CallableStatement> wrap_class1 = CallableStatement.class;
+
+ try {
+ //returning false is the correct behaviour in this case
+ //Generate a message if it returns true
+ if(conn.isWrapperFor(wrap_class1)) {
+ System.out.println("isWrapperFor wrongly returns true");
+ }
+ else {
+ CallableStatement stmt1 = (CallableStatement)
+ conn.unwrap(wrap_class1);
+ System.out.println("unwrap does not throw the expected " +
+ "exception");
+ }
+ }
+ catch (SQLException sqle) {
+ //calling unwrap in this case throws an SQLException
+ //ensure that this SQLException has the correct SQLState
+ if(!SQLStateConstants.UNABLE_TO_UNWRAP.equals(sqle.getSQLState())) {
+ sqle.printStackTrace();
+ }
+ }
+ }
+
public void startTestConnectionMethods_Client() {
t_createClob_Client();
t_createBlob_Client();
@@ -396,6 +452,7 @@
t_setClientInfo2();
t_getClientInfo1();
t_getClientInfo2();
+ t_wrapper();
}
/**
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java Tue Apr 11 06:58:02 2006
@@ -22,12 +22,14 @@
import java.sql.Connection;
import java.sql.DatabaseMetaData;
+import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import org.apache.derby.tools.ij;
+import org.apache.derbyTesting.functionTests.util.SQLStateConstants;
/**
* Test of database metadata for new methods in JDBC 40.
@@ -178,11 +180,23 @@
System.out.println("getSchemas():");
dumpSQLExceptions(e);
}
-
+
+ if(usingEmbeddedClient())
+ t_wrapper(met);
+
s.close();
}
/**
+ * <p>
+ * Return true if we're running under the embedded client.
+ * </p>
+ */
+ private static boolean usingEmbeddedClient() {
+ return "embedded".equals( System.getProperty( "framework" ) );
+ }
+
+ /**
* Test supportsStoredFunctionsUsingCallSyntax() by checking
* whether calling a stored procedure using the escape syntax
* succeeds.
@@ -327,4 +341,64 @@
throw new Exception("Unexpected SQL Exception: " + e.getMessage(), e);
}
}
+
+
+ /**
+ * Tests the wrapper methods isWrapperFor and unwrap. There are two cases
+ * to be tested
+ * Case 1: isWrapperFor returns true and we call unwrap
+ * Case 2: isWrapperFor returns false and we call unwrap
+ *
+ * @param dmd The DatabaseMetaData object on which the wrapper methods are
+ * called
+ */
+
+ static void t_wrapper(DatabaseMetaData dmd) {
+ //test for the case when isWrapper returns true
+ //Begin test for Case 1
+ Class<DatabaseMetaData> wrap_class = DatabaseMetaData.class;
+
+ //The if succeeds and we call the unwrap method on the conn object
+ try {
+ if(dmd.isWrapperFor(wrap_class)) {
+ DatabaseMetaData dmd1 =
+ (DatabaseMetaData)dmd.unwrap(wrap_class);
+ }
+ else {
+ System.out.println("isWrapperFor wrongly returns false");
+ }
+ }
+ catch(SQLException sqle) {
+ dumpSQLExceptions(sqle);
+ }
+
+ //Begin the test for Case 2
+ //test for the case when isWrapper returns false
+ //using some class that will return false when
+ //passed to isWrapperFor
+
+ Class<PreparedStatement> wrap_class1 = PreparedStatement.class;
+
+ try {
+ //returning false is the correct behaviour in this case
+ //Generate a message if it returns true
+ if(dmd.isWrapperFor(wrap_class1)) {
+ System.out.println("isWrapperFor wrongly returns true");
+ }
+ else {
+ PreparedStatement ps1 = (PreparedStatement)
+ dmd.unwrap(wrap_class1);
+ System.out.println("unwrap does not throw the expected " +
+ "exception");
+ }
+ }
+ catch (SQLException sqle) {
+ //calling unwrap in this case throws an
+ //SQLException ensure that the SQLException
+ //has the correct SQLState
+ if(!SQLStateConstants.UNABLE_TO_UNWRAP.equals(sqle.getSQLState())) {
+ sqle.printStackTrace();
+ }
+ }
+ }
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods.java?rev=393221&r1=393220&r2=393221&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods.java Tue Apr 11 06:58:02 2006
@@ -40,6 +40,8 @@
import org.apache.derby.shared.common.error.ExceptionUtil;
import org.apache.derby.shared.common.reference.SQLState;
import org.apache.derby.tools.ij;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derbyTesting.functionTests.util.SQLStateConstants;
/**
* This class is used to test the implementations of the JDBC 4.0 methods
* in the PreparedStatement interface
@@ -490,6 +492,58 @@
e.printStackTrace();
}
}
+
+ /**
+ * Tests the wrapper methods isWrapperFor and unwrap. There are two cases
+ * to be tested
+ * Case 1: isWrapperFor returns true and we call unwrap
+ * Case 2: isWrapperFor returns false and we call unwrap
+ */
+ void t_wrapper() {
+ Class<PreparedStatement> wrap_class = PreparedStatement.class;
+
+ //The if method succeeds enabling us to call the unwrap method without
+ //throwing an exception
+ try {
+ if(ps.isWrapperFor(wrap_class)) {
+ PreparedStatement stmt1 =
+ (PreparedStatement)ps.unwrap(wrap_class);
+ }
+ else {
+ System.out.println("isWrapperFor wrongly returns false");
+ }
+ }
+ catch(SQLException sqle) {
+ sqle.printStackTrace();
+ }
+
+ //Begin test for case2
+ //test for the case when isWrapper returns false
+ //using some class that will return false when
+ //passed to isWrapperFor
+ Class<ResultSet> wrap_class1 = ResultSet.class;
+
+ try {
+ //returning false is the correct behaviour in this case
+ //Generate a message if it returns true
+ if(ps.isWrapperFor(wrap_class1)) {
+ System.out.println("isWrapperFor wrongly returns true");
+ }
+ else {
+ ResultSet rs1 = (ResultSet)
+ ps.unwrap(wrap_class1);
+ System.out.println("unwrap does not throw the expected " +
+ "exception");
+ }
+ }
+ catch (SQLException sqle) {
+ //calling unwrap in this case throws an SQLException
+ //ensure that this SQLException has the correct SQLState
+ if(!SQLStateConstants.UNABLE_TO_UNWRAP.equals(sqle.getSQLState())) {
+ sqle.printStackTrace();
+ }
+ }
+ }
/*
* Start the tests for the JDBC4.0 methods on the client side
*/
@@ -576,6 +630,7 @@
t_setSQLXML();
t_isPoolable();
t_setPoolable();
+ t_wrapper();
// Close the prepared statement and verify the poolable hint
// cannot be set or retrieved
ps.close();