db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1443697 - in /db/derby/code/trunk/java: build/org/apache/derbyBuild/ client/org/apache/derby/client/am/ client/org/apache/derby/client/net/ engine/org/apache/derby/ engine/org/apache/derby/iapi/jdbc/ engine/org/apache/derby/iapi/types/ eng...
Date Thu, 07 Feb 2013 20:17:08 GMT
Author: rhillegas
Date: Thu Feb  7 20:17:08 2013
New Revision: 1443697

URL: http://svn.apache.org/r1443697
Log:
DERBY-6000: Add new PreparedStatement.setObject() overloads introduced by JDBC 4.2.

Added:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalPreparedStatement42.java   (with props)
    db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement42.java   (with props)
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Utils42.java   (with props)
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection42.java   (with props)
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement42.java   (with props)
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement42.java   (with props)
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util42.java   (with props)
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver42.java   (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest42.java   (with props)
Modified:
    db/derby/code/trunk/java/build/org/apache/derbyBuild/classlister.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/CrossConverters.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl42.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/build.xml
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/HarmonySerialBlob.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ConnectionChild.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/Util.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/build.xml
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/build.xml
    db/derby/code/trunk/java/engine/org/apache/derby/modules.properties
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/JDBC40Translation.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/_Suite.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/build.xml
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Price.java

Modified: db/derby/code/trunk/java/build/org/apache/derbyBuild/classlister.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/build/org/apache/derbyBuild/classlister.java?rev=1443697&r1=1443696&r2=1443697&view=diff
==============================================================================
--- db/derby/code/trunk/java/build/org/apache/derbyBuild/classlister.java (original)
+++ db/derby/code/trunk/java/build/org/apache/derbyBuild/classlister.java Thu Feb  7 20:17:08 2013
@@ -562,6 +562,13 @@ public class classlister {
 			InputStream is = locateClass(fileName, false);
 
 			if (is == null) {
+
+                //
+                // Until there is a Java 8 whose stubs can be used to build Derby, we will allow
+                // the build to complete without the JDBC 4.2 support.
+                //
+                if ( className.endsWith( "Driver42" ) ) { return; }
+                
 				pwOut.println("**error** Got NULL when looking for fileName = " + fileName);
 				if (!keepRolling)
 				{

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/CrossConverters.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/CrossConverters.java?rev=1443697&r1=1443696&r2=1443697&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/CrossConverters.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/CrossConverters.java Thu Feb  7 20:17:08 2013
@@ -957,6 +957,8 @@ final class CrossConverters {
             return setObject(targetType, new java.sql.Timestamp(  ((java.util.Date) source).getTime() ) );
         } else if (source instanceof java.util.Calendar) {
             return setObject(targetType, new java.sql.Timestamp(  ((java.util.Calendar) source).getTime().getTime() ) );
+        } else if (targetType == Types.JAVA_OBJECT) {
+            return source;
         } else {
             throw new SqlException(agent_.logWriter_, 
                 new ClientMessageId (SQLState.LANG_DATA_TYPE_SET_MISMATCH),

Added: 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=1443697&view=auto
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalPreparedStatement42.java (added)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalPreparedStatement42.java Thu Feb  7 20:17:08 2013
@@ -0,0 +1,64 @@
+/*
+
+   Derby - Class org.apache.derby.client.am.LogicalPreparedStatement42
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You 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.client.am;
+
+import java.sql.SQLException;
+import java.sql.SQLType;
+
+import org.apache.derby.client.am.stmtcache.StatementKey;
+
+/**
+ * JDBC 4.2 specific wrapper class for a Derby physical prepared statement.
+ */
+public class LogicalPreparedStatement42
+    extends LogicalPreparedStatement40
+{
+    /**
+     * Creates a new logical prepared statement.
+     *
+     * @param physicalPs underlying physical statement
+     * @param stmtKey key for the physical statement
+     * @param cacheInteractor creating statement cache interactor
+     * @throws IllegalArgumentException if {@code cache} is {@code null}
+     */
+    public LogicalPreparedStatement42
+        ( java.sql.PreparedStatement physicalPs, StatementKey stmtKey, StatementCacheInteractor cacheInteractor )
+    {
+        super(physicalPs, stmtKey, cacheInteractor);
+    }
+
+    public  void setObject
+        ( int parameterIndex, java.lang.Object x, SQLType targetSqlType )
+        throws SQLException
+    {
+        getPhysPs().setObject( parameterIndex, x, targetSqlType );
+    }
+    
+    public void setObject
+        (
+         int parameterIndex, java.lang.Object x,
+         SQLType targetSqlType, int scaleOrLength
+         )  throws SQLException
+    {
+        getPhysPs().setObject( parameterIndex, x, targetSqlType, scaleOrLength );
+    }
+
+}

Propchange: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalPreparedStatement42.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java?rev=1443697&r1=1443696&r2=1443697&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java Thu Feb  7 20:17:08 2013
@@ -2473,6 +2473,7 @@ public class PreparedStatement extends S
         case JDBC40Translation.NVARCHAR:
         case JDBC40Translation.LONGNVARCHAR:
         case java.sql.Types.REF:
+        case JDBC40Translation.REF_CURSOR:
         case JDBC40Translation.ROWID:
         case JDBC40Translation.SQLXML:
         case java.sql.Types.STRUCT:

Added: db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement42.java?rev=1443697&view=auto
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement42.java (added)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement42.java Thu Feb  7 20:17:08 2013
@@ -0,0 +1,119 @@
+/*
+
+   Derby - Class org.apache.derby.client.am.PreparedStatement42
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You 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.client.am;
+
+import java.sql.SQLException;
+import java.sql.SQLType;
+import org.apache.derby.client.ClientPooledConnection;
+
+public class  PreparedStatement42 extends  org.apache.derby.client.am.PreparedStatement40
+{
+    /**
+     * The PreparedStatement used for JDBC 4.2 positioned update statements.
+     * Called by material statement constructors.
+     * It has the ClientPooledConnection as one of its parameters 
+     * this is used to raise the Statement Events when the prepared
+     * statement is closed
+     */
+    public PreparedStatement42
+        (
+         Agent agent, Connection connection, String sql,
+         Section section,ClientPooledConnection cpc
+         ) throws SqlException
+    {
+        super(agent, connection,sql,section,cpc);
+    }
+    
+    /**
+     * The PreparedStatementConstructor used for jdbc 4.2 prepared statements 
+     * with scroll attributes. Called by material statement constructors.
+     * It has the ClientPooledConnection as one of its parameters 
+     * this is used to raise the Statement Events when the prepared
+     * statement is closed
+     */
+    public PreparedStatement42
+        (
+         Agent agent, Connection connection,String sql,
+         int type, int concurrency, int holdability, int autoGeneratedKeys, 
+         String[] columnNames, int[] columnIndexes, ClientPooledConnection cpc
+         ) throws SqlException
+    {
+        super(agent, connection, sql, type, concurrency, holdability, autoGeneratedKeys,
+                columnNames, columnIndexes, cpc);
+    }
+    
+    public  void setObject
+        ( int parameterIndex, java.lang.Object x, SQLType targetSqlType )
+        throws SQLException
+    {
+        synchronized (connection_)
+        {
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry( this, "setObject", parameterIndex, x, targetSqlType );
+            }
+            
+            checkStatus();
+            setObject
+                (
+                 parameterIndex, x,
+                 Utils42.getTypeAsInt( agent_, targetSqlType )
+                 );
+        }
+    }
+    
+    public void setObject
+        (
+         int parameterIndex, java.lang.Object x,
+         SQLType targetSqlType, int scaleOrLength
+         )  throws SQLException
+    {
+        synchronized (connection_)
+        {
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry
+                    ( this, "setObject", new Integer( parameterIndex ), x, targetSqlType, new Integer( scaleOrLength ) );
+            }
+            
+            checkStatus();
+            setObject
+                (
+                 parameterIndex, x,
+                 Utils42.getTypeAsInt( agent_, targetSqlType ),
+                 scaleOrLength
+                 );
+        }
+    }
+
+    /**
+     * <p>
+     * Check for closed statement and extract the SQLException if it is raised.
+     * </p>
+     */
+    private void    checkStatus() throws SQLException
+    {
+        try {
+            checkForClosedStatement();
+        }
+        catch (SqlException se) { throw se.getSQLException(); }
+    }
+
+}

Propchange: db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement42.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/client/org/apache/derby/client/am/Utils42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Utils42.java?rev=1443697&view=auto
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Utils42.java (added)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Utils42.java Thu Feb  7 20:17:08 2013
@@ -0,0 +1,59 @@
+/*
+
+   Derby - Class org.apache.derby.client.am.Utils42
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You 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.client.am;
+
+import java.sql.JDBCType;
+import java.sql.SQLException;
+import java.sql.SQLType;
+
+import org.apache.derby.shared.common.reference.SQLState;
+
+/**
+ * <p>
+ * Utility methods for JDBC 4.2.
+ * </p>
+ */
+public final class Utils42
+{
+    /**
+     * <p>
+     * Get the int type id from java.sql.Types which corresponds to the SQLType.
+     * </p>
+     */
+    public  static  int getTypeAsInt( Agent agent, SQLType sqlType )
+        throws SQLException
+    {
+        // must correspond to something in java.sql.Types
+        if ( sqlType instanceof JDBCType )
+        {
+            return ((JDBCType) sqlType).getVendorTypeNumber();
+        }
+
+        throw new SqlException
+            (
+             agent.logWriter_,
+             new ClientMessageId(SQLState.DATA_TYPE_NOT_SUPPORTED),
+             sqlType.toString()
+             ).getSQLException();
+    }
+
+}

Propchange: db/derby/code/trunk/java/client/org/apache/derby/client/am/Utils42.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=1443697&r1=1443696&r2=1443697&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 Thu Feb  7 20:17:08 2013
@@ -23,6 +23,17 @@ package org.apache.derby.client.net;
 
 import org.apache.derby.client.am.SqlException;
 
+import org.apache.derby.client.ClientPooledConnection;
+import org.apache.derby.client.am.Agent;
+import org.apache.derby.client.am.LogicalPreparedStatement;
+import org.apache.derby.client.am.LogicalPreparedStatement42;
+import org.apache.derby.client.am.PreparedStatement;
+import org.apache.derby.client.am.PreparedStatement42;
+import org.apache.derby.client.am.Section;
+import org.apache.derby.client.am.StatementCacheInteractor;
+import org.apache.derby.client.am.SqlException;
+import org.apache.derby.client.am.stmtcache.StatementKey;
+
 /**
  * Implements the ClientJDBCObjectFactory interface and returns the JDBC 4.2
  * specific classes.
@@ -35,6 +46,46 @@ public class ClientJDBCObjectFactoryImpl
     {
         return new java.sql.BatchUpdateException( message, sqlState, errorCode, updateCounts, cause );
     }
+
+    /**
+     * Returns a PreparedStatement.
+     */
+    public PreparedStatement newPreparedStatement(Agent agent,
+            org.apache.derby.client.am.Connection connection,
+            String sql,Section section,ClientPooledConnection cpc) 
+            throws SqlException {
+        return new PreparedStatement42(agent,connection,sql,section,cpc);
+    }
+    
+    /**
+     *
+     * This method returns an instance of PreparedStatement
+     * which implements java.sql.PreparedStatement.
+     * It has the ClientPooledConnection as one of its parameters
+     * this is used to raise the Statement Events when the prepared
+     * statement is closed.
+     */
+    public PreparedStatement newPreparedStatement(Agent agent,
+            org.apache.derby.client.am.Connection connection,
+            String sql,int type,int concurrency,
+            int holdability,int autoGeneratedKeys,
+            String [] columnNames,
+            int[] columnIndexes, ClientPooledConnection cpc) 
+            throws SqlException {
+        return new PreparedStatement42(agent,connection,sql,type,concurrency,
+                holdability,autoGeneratedKeys,columnNames,columnIndexes, cpc);
+    }
+
+    /**
+     * Returns a new logcial prepared statement object.
+     */
+    public LogicalPreparedStatement newLogicalPreparedStatement(
+            java.sql.PreparedStatement ps,
+            StatementKey stmtKey,
+            StatementCacheInteractor cacheInteractor) {
+        return new LogicalPreparedStatement42(ps, stmtKey, cacheInteractor);
+    }
+    
 }
 
     

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java?rev=1443697&r1=1443696&r2=1443697&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 Thu Feb  7 20:17:08 2013
@@ -263,7 +263,7 @@ public class BrokeredConnection40
             throw sqle;
         }
     }
-    public final BrokeredPreparedStatement newBrokeredStatement(BrokeredStatementControl statementControl, String sql, Object generatedKeys) throws SQLException {
+    public BrokeredPreparedStatement newBrokeredStatement(BrokeredStatementControl statementControl, String sql, Object generatedKeys) throws SQLException {
         try {
             return new BrokeredPreparedStatement40(statementControl, sql, generatedKeys);
         } catch (SQLException sqle) {

Added: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection42.java?rev=1443697&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection42.java (added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection42.java Thu Feb  7 20:17:08 2013
@@ -0,0 +1,46 @@
+/*
+ 
+   Derby - Class org.apache.derby.iapi.jdbc.BrokeredConnection42
+ 
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to you 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;
+
+public class BrokeredConnection42
+        extends BrokeredConnection40
+{
+    /** Creates a new instance of BrokeredConnection40 */
+    public BrokeredConnection42(BrokeredConnectionControl control)
+            throws SQLException {
+        super(control);
+    }
+    
+    public final BrokeredPreparedStatement newBrokeredStatement
+        ( BrokeredStatementControl statementControl, String sql, Object generatedKeys )
+        throws SQLException
+    {
+        try {
+            return new BrokeredPreparedStatement42( statementControl, sql, generatedKeys );
+        } catch (SQLException sqle) {
+            notifyException(sqle);
+            throw sqle;
+        }
+    }
+}

Propchange: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection42.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement42.java?rev=1443697&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement42.java (added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement42.java Thu Feb  7 20:17:08 2013
@@ -0,0 +1,51 @@
+/*
+ 
+   Derby - Class org.apache.derby.iapi.jdbc.BrokeredPreparedStatement42
+ 
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to you 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 java.sql.SQLType;
+
+public class BrokeredPreparedStatement42 extends BrokeredPreparedStatement40
+{
+    public BrokeredPreparedStatement42
+        (BrokeredStatementControl control, String sql, Object generatedKeys) throws SQLException
+    {
+        super( control, sql,generatedKeys );
+    }
+    
+    public  void setObject
+        ( int parameterIndex, java.lang.Object x, SQLType targetSQLType )
+        throws SQLException
+    {
+        getPreparedStatement().setObject( parameterIndex, x, targetSQLType );
+    }
+    
+    public void setObject
+        (
+         int parameterIndex, java.lang.Object x,
+         SQLType targetSQLType, int scaleOrLength
+         )  throws SQLException
+    {
+        getPreparedStatement().setObject( parameterIndex, x, targetSQLType, scaleOrLength );
+    }
+    
+}

Propchange: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement42.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/build.xml?rev=1443697&r1=1443696&r2=1443697&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 Thu Feb  7 20:17:08 2013
@@ -37,7 +37,7 @@
 
 <!-- Targets -->
 
-  <target name="compile" depends="compile_iapi_jdbc_jdbc3, compile_jdbc4"/>
+  <target name="compile" depends="checkVMLevel, compile_iapi_jdbc_jdbc3, compile_jdbc4, compile_jdbc42"/>
 
   <target name="compile_iapi_jdbc_jsr169">
 	    <javac
@@ -69,6 +69,7 @@
       <exclude name="${derby.dir}/${cur.dir}/EngineConnection40.java"/>
       <exclude name="${derby.dir}/${cur.dir}/FailedProperties40.java"/>
       <exclude name="${derby.dir}/${cur.dir}/ResourceAdapter.java"/>
+	  <exclude name="${derby.dir}/${cur.dir}/*42.java"/>
     </javac>
   </target>
 
@@ -125,5 +126,30 @@
       </javac>
   </target> 
 
+  <target name="compile_jdbc42" if="vmLevelIsAtLeast1.8">
+      <javac
+          source="${compilerLevel16}"
+          target="${compilerLevel16}"
+          bootclasspath="${empty}"
+          nowarn="on"
+          debug="${debug}"
+          depend="${depend}"
+          deprecation="${deprecation}"
+          optimize="${optimize}"
+          proceed="${proceed}"
+          verbose="${verbose}"
+          srcdir="${derby.engine.src.dir}"
+          destdir="${out.dir}">
+          <classpath>
+              <pathelement path="${java18compile.classpath}"/>
+          </classpath>
+          <include name="${derby.dir}/${cur.dir}/*42.java"/>
+      </javac>
+  </target> 
+
+  <target name="checkVMLevel">
+    <available classname="java.sql.SQLType" property="vmLevelIsAtLeast1.8" value="true"/>
+  </target>
+
 </project>
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/HarmonySerialBlob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/HarmonySerialBlob.java?rev=1443697&r1=1443696&r2=1443697&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/HarmonySerialBlob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/HarmonySerialBlob.java Thu Feb  7 20:17:08 2013
@@ -80,7 +80,7 @@ public class HarmonySerialBlob implement
      * @throws SQLException
      *             if a SQL error is encountered
      */
-    public HarmonySerialBlob(byte[] buf) throws SQLException {
+    public HarmonySerialBlob(byte[] buf) {
         this.buf = new byte[buf.length];
         len = buf.length;
         origLen = len;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java?rev=1443697&r1=1443696&r2=1443697&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java Thu Feb  7 20:17:08 2013
@@ -167,12 +167,7 @@ public class SQLBlob extends SQLBinary
             if ( bytes == null ) { return null; }
             else
             {
-                try {
-                    return new HarmonySerialBlob( bytes );
-                } catch (SQLException se)
-                {
-                    throw StandardException.plainWrapException( se );
-                }
+                return new HarmonySerialBlob( bytes );
             }
         }
     }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java?rev=1443697&r1=1443696&r2=1443697&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java Thu Feb  7 20:17:08 2013
@@ -160,6 +160,7 @@ public final class TypeId
         public static final String      LONGVARBINARY_NAME = "LONGVARBINARY";
         public static final String      BOOLEAN_NAME = "BOOLEAN";
         public static final String      REF_NAME = "REF";
+        public static final String      REF_CURSOR = "REF CURSOR";
         public static final String      NATIONAL_CHAR_NAME = "NATIONAL CHAR";
         public static final String      NATIONAL_VARCHAR_NAME = "NATIONAL CHAR VARYING";
         public static final String      NATIONAL_LONGVARCHAR_NAME = "LONG NVARCHAR";

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ConnectionChild.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ConnectionChild.java?rev=1443697&r1=1443696&r2=1443697&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ConnectionChild.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ConnectionChild.java Thu Feb  7 20:17:08 2013
@@ -22,9 +22,12 @@
 package org.apache.derby.impl.jdbc;
 
 import org.apache.derby.jdbc.InternalDriver;
+import org.apache.derby.iapi.reference.JDBC40Translation;
+import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.util.InterruptStatus;
 
 import java.sql.SQLException;
+import java.sql.Types;
 
 /**
 	Any class in the embedded JDBC driver (ie this package) that needs to
@@ -145,6 +148,44 @@ abstract class ConnectionChild {
 		return cal;
 	}
 
+    /**
+     * Checks whether a data type is supported for
+     * <code>setObject(int, Object, int)</code> and
+     * <code>setObject(int, Object, int, int)</code>.
+     *
+     * @param dataType the data type to check
+     * @exception SQLException if the type is not supported
+     */
+    public void checkForSupportedDataType(int dataType) throws SQLException {
+
+        // JDBC 4.0 javadoc for setObject() says:
+        //
+        // Throws: (...) SQLFeatureNotSupportedException - if
+        // targetSqlType is a ARRAY, BLOB, CLOB, DATALINK,
+        // JAVA_OBJECT, NCHAR, NCLOB, NVARCHAR, LONGNVARCHAR, REF,
+        // ROWID, SQLXML or STRUCT data type and the JDBC driver does
+        // not support this data type
+        //
+        // Of these types, we only support BLOB, CLOB and
+        // (sort of) JAVA_OBJECT.
+
+        switch (dataType) {
+        case Types.ARRAY:
+        case Types.DATALINK:
+        case JDBC40Translation.NCHAR:
+        case JDBC40Translation.NCLOB:
+        case JDBC40Translation.NVARCHAR:
+        case JDBC40Translation.LONGNVARCHAR:
+        case Types.REF:
+        case JDBC40Translation.REF_CURSOR:
+        case JDBC40Translation.ROWID:
+        case JDBC40Translation.SQLXML:
+        case Types.STRUCT:
+            throw newSQLException(SQLState.DATA_TYPE_NOT_SUPPORTED,
+                                  Util.typeName(dataType));
+        }
+    }
+
 	SQLException newSQLException(String messageId) {
 		return localConn.newSQLException(messageId);
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java?rev=1443697&r1=1443696&r2=1443697&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 Thu Feb  7 20:17:08 2013
@@ -38,7 +38,6 @@ import org.apache.derby.iapi.types.Reade
 import org.apache.derby.iapi.error.StandardException;
 
 import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.iapi.reference.JDBC40Translation;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
@@ -1782,43 +1781,6 @@ public class EmbedPreparedStatement
             throw sqle;
         }
 
-    /**
-     * Checks whether a data type is supported for
-     * <code>setObject(int, Object, int)</code> and
-     * <code>setObject(int, Object, int, int)</code>.
-     *
-     * @param dataType the data type to check
-     * @exception SQLException if the type is not supported
-     */
-    private void checkForSupportedDataType(int dataType) throws SQLException {
-
-        // JDBC 4.0 javadoc for setObject() says:
-        //
-        // Throws: (...) SQLFeatureNotSupportedException - if
-        // targetSqlType is a ARRAY, BLOB, CLOB, DATALINK,
-        // JAVA_OBJECT, NCHAR, NCLOB, NVARCHAR, LONGNVARCHAR, REF,
-        // ROWID, SQLXML or STRUCT data type and the JDBC driver does
-        // not support this data type
-        //
-        // Of these types, we only support BLOB, CLOB and
-        // (sort of) JAVA_OBJECT.
-
-        switch (dataType) {
-        case Types.ARRAY:
-        case Types.DATALINK:
-        case JDBC40Translation.NCHAR:
-        case JDBC40Translation.NCLOB:
-        case JDBC40Translation.NVARCHAR:
-        case JDBC40Translation.LONGNVARCHAR:
-        case Types.REF:
-        case JDBC40Translation.ROWID:
-        case JDBC40Translation.SQLXML:
-        case Types.STRUCT:
-            throw newSQLException(SQLState.DATA_TYPE_NOT_SUPPORTED,
-                                  Util.typeName(dataType));
-        }
-    }
-
    //jdbc 4.0 methods
 
     /**

Added: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement42.java?rev=1443697&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement42.java (added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement42.java Thu Feb  7 20:17:08 2013
@@ -0,0 +1,77 @@
+/*
+ 
+   Derby - Class org.apache.derby.impl.jdbc.EmbedPreparedStatement42
+ 
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to you 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.JDBCType;
+import java.sql.SQLException;
+import java.sql.SQLType;
+import java.sql.Types;
+
+import org.apache.derby.iapi.reference.SQLState;
+
+/**
+ * <p>
+ * PreparedStatement methods added by JDBC 4.2 which require Java 8.
+ * </p>
+ */
+public class EmbedPreparedStatement42 extends EmbedPreparedStatement40
+{    
+    public EmbedPreparedStatement42
+        (
+         EmbedConnection conn, String sql, boolean forMetaData,
+         int resultSetType, int resultSetConcurrency, int resultSetHoldability,
+         int autoGeneratedKeys, int[] columnIndexes, String[] columnNames
+         ) throws SQLException
+    {
+        super(conn, sql, forMetaData, resultSetType, resultSetConcurrency, resultSetHoldability,
+            autoGeneratedKeys, columnIndexes, columnNames);
+    }
+
+    public  void setObject
+        ( int parameterIndex, java.lang.Object x, SQLType targetSqlType )
+        throws SQLException
+    {
+        checkStatus();
+        setObject
+            (
+             parameterIndex, x,
+             Util42.getTypeAsInt( this, targetSqlType )
+             );
+    }
+    
+    public void setObject
+        (
+         int parameterIndex, java.lang.Object x,
+         SQLType targetSqlType, int scaleOrLength
+         )  throws SQLException
+    {
+        checkStatus();
+        setObject
+            (
+             parameterIndex, x,
+             Util42.getTypeAsInt( this, targetSqlType ),
+             scaleOrLength
+             );
+    }
+
+}    
+

Propchange: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement42.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java?rev=1443697&r1=1443696&r2=1443697&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java Thu Feb  7 20:17:08 2013
@@ -445,6 +445,7 @@ public abstract class Util  {
 			case Types.OTHER		:  return "OTHER";
 			case Types.JAVA_OBJECT	:  return "Types.JAVA_OBJECT";
 			case Types.REF : return TypeId.REF_NAME;
+			case JDBC40Translation.REF_CURSOR: return TypeId.REF_CURSOR;
 			case JDBC40Translation.ROWID: return TypeId.ROWID_NAME;
 			case Types.STRUCT: return TypeId.STRUCT_NAME;
 			case StoredFormatIds.XML_TYPE_ID :  return TypeId.XML_NAME;

Added: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util42.java?rev=1443697&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util42.java (added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util42.java Thu Feb  7 20:17:08 2013
@@ -0,0 +1,61 @@
+/*
+ 
+   Derby - Class org.apache.derby.impl.jdbc.Util42
+ 
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to you 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.JDBCType;
+import java.sql.SQLException;
+import java.sql.SQLType;
+import java.sql.Types;
+
+import org.apache.derby.iapi.reference.SQLState;
+
+/**
+ * <p>
+ * Utility methods for JDBC 4.2
+ * </p>
+ */
+public class Util42
+{    
+    /**
+     * <p>
+     * Get the int type id from java.sql.Types which corresponds to the SQLType.
+     * </p>
+     */
+    public  static  int getTypeAsInt( ConnectionChild connChild, SQLType sqlType )
+        throws SQLException
+    {
+        // must correspond to something in java.sql.Types
+        if ( sqlType instanceof JDBCType )
+        {
+            int     jdbcType = ((JDBCType) sqlType).getVendorTypeNumber();
+            
+            connChild.checkForSupportedDataType( jdbcType );
+        
+            return jdbcType;
+        }
+
+        throw connChild.newSQLException
+            ( SQLState.DATA_TYPE_NOT_SUPPORTED, sqlType.toString() );
+    }
+    
+}    
+

Propchange: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util42.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/build.xml?rev=1443697&r1=1443696&r2=1443697&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/build.xml (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/build.xml Thu Feb  7 20:17:08 2013
@@ -34,7 +34,7 @@
 
 <!-- Targets -->
 
-  <target name="compile" depends="compile_jdbc3, compile_jdbc4"/>
+  <target name="compile" depends="checkVMLevel, compile_jdbc3, compile_jdbc4, compile_jdbc42"/>
 
   <target name="compile_jsr169">
 	    <javac
@@ -57,6 +57,7 @@
 	  <exclude name="${derby.dir}/impl/jdbc/*20.java"/>
 	  <exclude name="${derby.dir}/impl/jdbc/*30.java"/>
 	  <exclude name="${derby.dir}/impl/jdbc/*40.java"/>
+	  <exclude name="${derby.dir}/impl/jdbc/*42.java"/>
 	  <exclude name="${derby.dir}/impl/jdbc/LOBStoredProcedure.java"/>
 
 	  <include name="${derby.dir}/impl/jdbc/authentication/**"/>
@@ -109,6 +110,33 @@
         </classpath>
         <include name="${derby.dir}/impl/jdbc/*40.java"/>
     </javac>
-</target> 
+</target>
+
+
+<target name="compile_jdbc42" depends="compile_jdbc4"  if="vmLevelIsAtLeast1.8">
+    <javac
+      source="${compilerLevel16}"
+      target="${compilerLevel16}"
+        bootclasspath="${empty}"
+        nowarn="on"
+        debug="${debug}"
+        depend="${depend}"
+        deprecation="${deprecation}"
+        optimize="${optimize}"
+        proceed="${proceed}"
+        verbose="${verbose}"
+        srcdir="${derby.engine.src.dir}"
+        destdir="${out.dir}">
+        <classpath>
+            <pathelement path="${java18compile.classpath}"/>
+        </classpath>
+        <include name="${derby.dir}/impl/jdbc/*42.java"/>
+    </javac>
+</target>
+
+<target name="checkVMLevel">
+  <available classname="java.sql.SQLType" property="vmLevelIsAtLeast1.8" value="true"/>
+</target>
+
 </project>
 

Added: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver42.java?rev=1443697&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver42.java (added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver42.java Thu Feb  7 20:17:08 2013
@@ -0,0 +1,75 @@
+/*
+ 
+   Derby - Class org.apache.derby.jdbc.Driver42
+ 
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You 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.jdbc;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+import org.apache.derby.iapi.jdbc.BrokeredConnection;
+import org.apache.derby.iapi.jdbc.BrokeredConnectionControl;
+import org.apache.derby.iapi.jdbc.BrokeredConnection42;
+
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.impl.jdbc.EmbedPreparedStatement42;
+import org.apache.derby.impl.jdbc.EmbedConnection;
+
+/**
+ * <p>
+ * Embedded JDBC driver for JDBC 4.2.
+ * </p>
+ */
+public class Driver42 extends Driver40
+{
+    public PreparedStatement newEmbedPreparedStatement
+        (
+         EmbedConnection conn,
+         String stmt,
+         boolean forMetaData,
+         int resultSetType,
+         int resultSetConcurrency,
+         int resultSetHoldability,
+         int autoGeneratedKeys,
+         int[] columnIndexes,
+         String[] columnNames
+         )  throws SQLException
+    {
+        return new EmbedPreparedStatement42
+            (
+             conn,
+             stmt,
+             forMetaData,
+             resultSetType,
+             resultSetConcurrency,
+             resultSetHoldability,
+             autoGeneratedKeys,
+             columnIndexes,
+             columnNames
+             );
+    }
+
+    public BrokeredConnection newBrokeredConnection(
+            BrokeredConnectionControl control) throws SQLException {
+        return new BrokeredConnection42(control);
+    }
+    
+}

Propchange: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver42.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/build.xml?rev=1443697&r1=1443696&r2=1443697&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/build.xml (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/build.xml Thu Feb  7 20:17:08 2013
@@ -33,7 +33,7 @@
   <property file="${properties.dir}/compilepath.properties"/>
 
 <!-- Targets -->
-  <target name="jdbc" depends="compile_jdbc3,compile_jdbc4"/>
+  <target name="jdbc" depends="checkVMLevel,compile_jdbc3,compile_jdbc4,compile_jdbc42"/>
 
 <!-- build targets which need JDBC 3.0 libs in the end-->
 <!-- first build all non-special (non-JDBC 3.0) targets-->
@@ -116,7 +116,32 @@
         </classpath>
         <include name="${derby.dir}/jdbc/*40.java"/>
     </javac>
+  </target> 
 
+  <target name="compile_jdbc42" if="vmLevelIsAtLeast1.8">
+    <javac
+      source="${compilerLevel16}"
+      target="${compilerLevel16}"
+        bootclasspath="${empty}"
+        nowarn="on"
+        debug="${debug}"
+        depend="${depend}"
+        deprecation="${deprecation}"
+        optimize="${optimize}"
+        proceed="${proceed}"
+        verbose="${verbose}"
+        srcdir="${derby.engine.src.dir}"
+        destdir="${out.dir}">
+        <classpath>
+            <pathelement path="${java18compile.classpath}"/>
+        </classpath>
+        <include name="${derby.dir}/jdbc/*42.java"/>
+    </javac>
   </target> 
+
+  <target name="checkVMLevel">
+    <available classname="java.sql.SQLType" property="vmLevelIsAtLeast1.8" value="true"/>
+  </target>
+
 </project>
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/modules.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/modules.properties?rev=1443697&r1=1443696&r2=1443697&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/modules.properties (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/modules.properties Thu Feb  7 20:17:08 2013
@@ -189,6 +189,13 @@ derby.env.jdk.jdbcJ6=7
 derby.env.classes.jdbcJ6=java.sql.Driver
 cloudscape.config.jdbcJ6=derby
 
+# jdbc42 - requires JDK 1.8 (which is constant 9 in Derby)
+#
+derby.module.jdbcJ8=org.apache.derby.jdbc.Driver42
+derby.env.jdk.jdbcJ8=9
+derby.env.classes.jdbcJ8=java.sql.Driver
+cloudscape.config.jdbcJ8=derby
+
 # resourceAdapter - requires JDK 1.2, JTA classes and JDBC20X classes
 #
 derby.module.resourceAdapterJ2=org.apache.derby.jdbc.ResourceAdapterImpl

Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/JDBC40Translation.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/JDBC40Translation.java?rev=1443697&r1=1443696&r2=1443697&view=diff
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/JDBC40Translation.java (original)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/JDBC40Translation.java Thu Feb  7 20:17:08 2013
@@ -66,5 +66,6 @@ public interface JDBC40Translation {
     public static final int LONGNVARCHAR = -16;
     public static final int NCLOB = 2011;
     public static final int ROWID = -8;
+    public static final int REF_CURSOR = 2012;
     public static final int SQLXML = 2009;
 }

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest42.java?rev=1443697&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest42.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest42.java Thu Feb  7 20:17:08 2013
@@ -0,0 +1,356 @@
+/*
+ *
+ * Derby - Class org.apache.derbyTesting.functionTests.tests.jdbc4.PreparedStatementTest42
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you 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.math.BigDecimal;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.Date;
+import java.sql.JDBCType;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Time;
+import java.sql.Timestamp;
+
+import junit.framework.*;
+
+import org.apache.derby.iapi.types.HarmonySerialBlob;
+import org.apache.derby.iapi.types.HarmonySerialClob;
+
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.TestConfiguration;
+import org.apache.derbyTesting.functionTests.tests.lang.Price;
+
+/**
+ * Tests for new methods added for PreparedStatement in JDBC 4.2.
+ */
+public class PreparedStatementTest42 extends BaseJDBCTestCase
+{
+    //////////////////////////////////////////////////////////
+    //
+    // CONSTANTS
+    //
+    //////////////////////////////////////////////////////////
+
+    //
+    // If any of these becomes a legal Derby type, remove it from this table and put a corresponding line
+    // into _columnDescs.
+    //
+    private static  final   JDBCType[]  ILLEGAL_JDBC_TYPES = new JDBCType[]
+    {
+        JDBCType.ARRAY,
+        JDBCType.DATALINK,
+        JDBCType.NCHAR,
+        JDBCType.NCLOB,
+        JDBCType.NVARCHAR,
+        JDBCType.REF,
+        JDBCType.REF_CURSOR,
+        JDBCType.ROWID,
+        JDBCType.SQLXML,
+        JDBCType.STRUCT,
+        JDBCType.TINYINT,
+    };
+
+    //////////////////////////////////////////////////////////
+    //
+    // STATE
+    //
+    //////////////////////////////////////////////////////////
+
+    private static  ColumnDesc[]    _columnDescs =
+    {
+        new ColumnDesc( JDBCType.BIGINT, "bigint", new Long( 0L ), new Long( 1L ), null ),
+        new ColumnDesc( JDBCType.BLOB, "blob", makeBlob( "01234" ), makeBlob( "56789" ), null ),
+        new ColumnDesc( JDBCType.BOOLEAN, "boolean", Boolean.FALSE, Boolean.TRUE, null ),
+        new ColumnDesc( JDBCType.CHAR, "char( 5 )", "01234", "56789", null ),
+        new ColumnDesc( JDBCType.BINARY, "char( 5 ) for bit data", makeBinary( "01234" ), makeBinary( "56789" ), null ),
+        new ColumnDesc( JDBCType.CLOB, "clob", makeClob( "01234" ), makeClob( "56789" ), null ),
+        new ColumnDesc( JDBCType.DATE, "date", new Date( 0L ), new Date( 1L ), null ),
+        new ColumnDesc( JDBCType.DECIMAL, "decimal", new BigDecimal( 0 ), new BigDecimal( 1 ), null ),
+        new ColumnDesc( JDBCType.DOUBLE, "double", new Double( 0.0 ), new Double( 1.0 ), null ),
+        new ColumnDesc( JDBCType.FLOAT, "float", new Double( 0.0 ), new Double( 1.0 ), null ),
+        new ColumnDesc( JDBCType.INTEGER, "int", new Integer( 0 ), new Integer( 1 ), null ),
+        new ColumnDesc( JDBCType.LONGVARCHAR, "long varchar", "01234", "56789", null ),
+        new ColumnDesc( JDBCType.LONGVARBINARY, "long varchar for bit data", makeBinary( "01234" ), makeBinary( "56789" ), null ),
+        new ColumnDesc( JDBCType.NUMERIC, "numeric", new BigDecimal( 0 ), new BigDecimal( 1 ), null ),
+        new ColumnDesc( JDBCType.REAL, "float", new Float( 0.0F ), new Float( 1F ), null ),
+        new ColumnDesc( JDBCType.SMALLINT, "smallint", new Short( (short) 0 ), new Short( (short) 1 ), null ),
+        new ColumnDesc( JDBCType.TIME, "time", new Time( 0L ), new Time( 1L ), null ),
+        new ColumnDesc( JDBCType.TIMESTAMP, "timestamp", new Timestamp( 0L ), new Timestamp( 1L ), null ),
+        new ColumnDesc( JDBCType.JAVA_OBJECT, "Price", makePrice( 0L ), makePrice( 1L ), null ),
+        new ColumnDesc( JDBCType.VARCHAR, "varchar( 5 )", "01234", "56789", null ),
+        new ColumnDesc( JDBCType.VARBINARY, "varchar( 5 ) for bit data", makeBinary( "01234" ), makeBinary( "56789" ), null ),
+        // get/setObject on XML not supported because Derby does not support SQLXML yet
+    };
+
+    //////////////////////////////////////////////////////////
+    //
+    // NESTED CLASSES
+    //
+    //////////////////////////////////////////////////////////
+
+    public  static  final   class   ColumnDesc
+    {
+        public  static  final   int VALUE_COUNT = 3;
+        
+        public  final   JDBCType    jdbcType;
+        public  final   String          sqlType;
+        public  final   Object[]    values;
+
+        public  ColumnDesc
+            (
+             JDBCType    jdbcType,
+             String          sqlType,
+             Object...  values
+             )
+        {
+            this.jdbcType = jdbcType;
+            this.sqlType = sqlType;
+            this.values = values;
+
+            if ( values.length != VALUE_COUNT )
+            {
+                throw new IllegalArgumentException( "Expected " + VALUE_COUNT + " values but saw " + values.length );
+            }
+        }
+    }
+
+    //////////////////////////////////////////////////////////
+    //
+    // CONSTRUCTOR
+    //
+    //////////////////////////////////////////////////////////
+
+    /**
+     * Create a new test with the given name.
+     */
+    public PreparedStatementTest42( String name ) { super(name); }
+
+    //////////////////////////////////////////////////////////
+    //
+    // JUnit MACHINERY
+    //
+    //////////////////////////////////////////////////////////
+
+    public static Test suite()
+    {
+        TestSuite suite = new TestSuite("PreparedStatementTest42");
+
+        suite.addTest( TestConfiguration.defaultSuite( PreparedStatementTest42.class ) );
+
+        return suite;
+    }
+    
+    //////////////////////////////////////////////////////////
+    //
+    // TESTS
+    //
+    //////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Test the setObject() overloads added by JDBC 4.2.
+     * </p>
+     */
+    public  void    test_01_setObject() throws Exception
+    {
+        Connection conn = getConnection();
+
+        makeTable( conn );
+        populateTable( conn );
+        vetTableContents( conn );
+    }
+    private void    makeTable( Connection conn ) throws Exception
+    {
+        conn.prepareStatement
+            (
+             "create type Price external name 'org.apache.derbyTesting.functionTests.tests.lang.Price' language java"
+             ).execute();
+        
+        StringBuilder   buffer = new StringBuilder();
+
+        buffer.append( "create table allTypes\n(\n" );
+        buffer.append( "\tcol0\tint generated always as identity" );
+        for ( int i = 0; i < _columnDescs.length; i++ )
+        {
+            ColumnDesc  cd = _columnDescs[ i ];
+            String  columnName = "col" + (i+1);
+            String  columnType = cd.sqlType;
+            buffer.append( "\n\t, " + columnName + "\t" + columnType );
+        }
+        buffer.append( "\n)" );
+
+        conn.prepareStatement( buffer.toString() ).execute();
+    }
+    private void    populateTable( Connection conn ) throws Exception
+    {
+        StringBuilder   columnBuffer = new StringBuilder();
+        StringBuilder   valuesBuffer = new StringBuilder();
+
+        columnBuffer.append( "( " );
+        valuesBuffer.append( "( " );
+        for ( int i = 0; i < _columnDescs.length; i++ )
+        {
+            String  columnName = "col" + (i+1);
+            if ( i > 0 )
+            {
+                columnBuffer.append( ", " );
+                valuesBuffer.append( ", " );
+            }
+            columnBuffer.append( columnName );
+            valuesBuffer.append( "?" );
+        }
+        columnBuffer.append( " )" );
+        valuesBuffer.append( " )" );
+
+        PreparedStatement   insert = conn.prepareStatement
+            ( "insert into allTypes " + columnBuffer.toString() + " values " + valuesBuffer.toString() );
+
+        for ( int rowIdx = 0; rowIdx < ColumnDesc.VALUE_COUNT; rowIdx++ )
+        {
+            for ( int colIdx = 0; colIdx < _columnDescs.length; colIdx++ )
+            {
+                ColumnDesc  cd = _columnDescs[ colIdx ];
+                insert.setObject( colIdx + 1, cd.values[ rowIdx ], cd.jdbcType );
+            }
+            insert.executeUpdate();
+        }
+
+        for ( int rowIdx = 0; rowIdx < ColumnDesc.VALUE_COUNT; rowIdx++ )
+        {
+            for ( int colIdx = 0; colIdx < _columnDescs.length; colIdx++ )
+            {
+                ColumnDesc  cd = _columnDescs[ colIdx ];
+                insert.setObject( colIdx + 1, cd.values[ rowIdx ], cd.jdbcType, 0 );
+            }
+            insert.executeUpdate();
+        }
+
+
+        // verify that certain SQLTypes are illegal
+        for ( int i = 0; i < ILLEGAL_JDBC_TYPES.length; i++ )
+        {
+            try {
+                insert.setObject( 1, null, ILLEGAL_JDBC_TYPES[ i ] );
+            }
+            catch (SQLException se)
+            {
+                assertSQLState( "0A000", se );
+            }
+        }
+
+        insert.close();
+    }
+    private void    vetTableContents( Connection conn ) throws Exception
+    {
+        PreparedStatement   selectPS = conn.prepareStatement( "select * from allTypes order by col0" );
+        ResultSet               selectRS = selectPS.executeQuery();
+        int                     rowCount = 0;
+
+        while( selectRS.next() )
+        {
+            int     rowIdx = rowCount % ColumnDesc.VALUE_COUNT;
+
+            for ( int colIdx = 0; colIdx < _columnDescs.length; colIdx++ )
+            {
+                Object          expected = _columnDescs[ colIdx ].values[ rowIdx ];
+
+                // skip the first column, the primary key
+                assertObjectEquals( expected, selectRS.getObject( colIdx + 2 ) );
+            }
+
+            rowCount++;
+        }
+        
+        selectRS.close();
+        selectPS.close();
+    }
+
+    //////////////////////////////////////////////////////////
+    //
+    // MINIONS
+    //
+    //////////////////////////////////////////////////////////
+
+    private  static  Blob    makeBlob( String contents )
+    {
+        return new HarmonySerialBlob( makeBinary( contents ) );
+    }
+
+    private  static  Clob    makeClob( String contents )
+    {
+        return new HarmonySerialClob( contents );
+    }
+
+    private  static  byte[]    makeBinary( String contents )
+    {
+        try {
+            return contents.getBytes( "UTF-8" );
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    private static  Price   makePrice( long raw )
+    {
+        return Price.makePrice( new BigDecimal( raw ) );
+    }
+
+    private void    assertObjectEquals( Object expected, Object actual ) throws Exception
+    {
+        if ( expected == null )
+        {
+            assertNull( actual );
+            return;
+        }
+        else if ( actual == null )
+        {
+            assertNull( expected );
+            return;
+        }
+        else if ( expected instanceof Blob ) { assertEquals( (Blob) expected, (Blob) actual ); }
+        else if ( expected instanceof Clob ) { assertEquals( (Clob) expected, (Clob) actual ); }
+        else if ( expected instanceof byte[] ) { compareBytes( (byte[]) expected, (byte[]) actual ); }
+        else { assertEquals( expected.toString(), actual.toString() ); }
+    }
+    private void  compareBytes( byte[] left, byte[] right )
+        throws Exception
+    {
+        int count = left.length;
+        
+        if ( count != right.length )
+        {
+            fail("left count = " + count + " but right count = " + right.length );
+        }
+        for ( int i = 0; i < count; i++ )
+        {
+            if ( left[ i ] != right[ i ] )
+            {
+                fail( "left[ " + i + " ] = " + left[ i ] + " but right[ " + i + " ] = " + right[ i ] );
+            }
+        }
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest42.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/_Suite.java?rev=1443697&r1=1443696&r2=1443697&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/_Suite.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/_Suite.java Thu Feb  7 20:17:08 2013
@@ -21,6 +21,7 @@
 */
 package org.apache.derbyTesting.functionTests.tests.jdbc4;
 
+import java.lang.reflect.Method;
 import java.sql.SQLException;
 
 import org.apache.derbyTesting.junit.BaseTestCase;
@@ -48,7 +49,7 @@ public class _Suite extends BaseTestCase
 
         // These really need to run standalone.
 		//suite.addTestSuite(AutoloadBooting.class);
-        
+
 		suite.addTest(BlobTest.suite());
 		suite.addTest(CallableStatementTest.suite());
 		suite.addTest(ClobTest.suite());
@@ -78,7 +79,30 @@ public class _Suite extends BaseTestCase
         suite.addTest(AbortTest.suite());
         suite.addTest(Driver40Test.suite());
         suite.addTest(Driver40UnbootedTest.suite());
+
+        if ( isJava8() )
+        {
+            suite.addTest( getSuite( "org.apache.derbyTesting.functionTests.tests.jdbc4.PreparedStatementTest42" ) );
+        }
 		
 		return suite;
 	}
+
+    /**
+     * <p>
+     * Get the test suite from a class name.
+     * </p>
+     */
+    private static  Test    getSuite( String className )
+        throws SQLException
+    {
+        try {
+            Class<?>   klass = Class.forName( className );
+            Method  suiteMethod = klass.getMethod( "suite", new Class<?>[] {} );
+
+            return (Test) suiteMethod.invoke( null, new Object[] {} );
+        }
+        catch (Exception e) { throw new SQLException( e.getMessage(), e ); }
+    }
+    
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/build.xml?rev=1443697&r1=1443696&r2=1443697&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/build.xml (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/build.xml Thu Feb  7 20:17:08 2013
@@ -65,6 +65,31 @@
 		        <pathelement path="${junit}"/>
             </classpath>
             <include name="${this.dir}/*.java"/>
+            <exclude name="${this.dir}/*42.java"/>
+            <compilerarg value="-Xlint"/>
+        </javac>
+    </target>	
+
+    <target name="compile_jdbc42" if="vmLevelIsAtLeast1.8">
+        <javac
+          source="${compilerLevel16}"
+          target="${compilerLevel16}"
+            bootclasspath="${empty}"
+            nowarn="on"
+            debug="true"
+            depend="${depend}"
+            deprecation="${deprecation}"
+            optimize="${optimize}"
+            proceed="${proceed}"
+            verbose="${verbose}" 
+            srcdir="${derby.testing.src.dir}"
+            destdir="${out.dir}">
+            <classpath>
+                <pathelement path="${java18compile.classpath}"/>
+		        <pathelement path="${junit}"/>
+            </classpath>
+            <include name="${this.dir}/*42.java"/>
+            <compilerarg value="-Xlint"/>
         </javac>
     </target>	
 
@@ -75,6 +100,10 @@
         </copy>
     </target>
     
-    <target name="compile" depends="compile_jdbc4"/>
+    <target name="compile" depends="checkVMLevel,compile_jdbc4,compile_jdbc42"/>
+
+    <target name="checkVMLevel">
+      <available classname="java.sql.SQLType" property="vmLevelIsAtLeast1.8" value="true"/>
+    </target>
 
 </project>

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Price.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Price.java?rev=1443697&r1=1443696&r2=1443697&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Price.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/Price.java Thu Feb  7 20:17:08 2013
@@ -46,7 +46,8 @@ public class Price implements Externaliz
     public Timestamp timeInstant;
 
     // methods to be registered as functions
-    public static Price makePrice( ) { return new Price( "USD", BigDecimal.valueOf(1L), DEFAULT_TIMESTAMP ); }
+    public static Price makePrice( ) { return makePrice( BigDecimal.valueOf(1L) ); }
+    public static Price makePrice( BigDecimal cost ) { return new Price( "USD", cost, DEFAULT_TIMESTAMP ); }
     public static Price makePrice( String currencyCode, BigDecimal amount, Timestamp timeInstant ) { return new Price( currencyCode, amount, timeInstant ); }
     public static String getCurrencyCode( Price price ) { return price.currencyCode; }
     public static BigDecimal getAmount( Price price ) { return price.amount; }



Mime
View raw message