db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1444960 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ client/org/apache/derby/client/net/ engine/org/apache/derby/iapi/jdbc/ engine/org/apache/derby/impl/jdbc/ engine/org/apache/derby/jdbc/ testing/org/apache/derbyTest...
Date Mon, 11 Feb 2013 20:59:20 GMT
Author: rhillegas
Date: Mon Feb 11 20:59:19 2013
New Revision: 1444960

URL: http://svn.apache.org/r1444960
Log:
DERBY-6000: Add new CallableStatement.registerOutParameter() overloads introduced by JDBC
4.2.

Added:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement42.java  
(with props)
    db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement42.java
  (with props)
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement42.java
  (with props)
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement42.java
  (with props)
Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement.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/BrokeredConnection42.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver42.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest42.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/XA40Test.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CallableTest.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement.java?rev=1444960&r1=1444959&r2=1444960&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement.java Mon
Feb 11 20:59:19 2013
@@ -192,11 +192,12 @@ public class CallableStatement extends P
         parameterRegistered_[parameterIndex - 1] = true;
     }
 
+    /** Derby ignores the typeName argument because UDTs don't need it */
     public void registerOutParameter(int parameterIndex, int jdbcType, String typeName) throws
SQLException {
         if (agent_.loggingEnabled()) {
             agent_.logWriter_.traceEntry(this, "registerOutParameter", parameterIndex, jdbcType,
typeName);
         }
-        throw jdbcMethodNotImplemented();
+        registerOutParameter( parameterIndex, jdbcType );
     }
 
     public boolean wasNull() throws SQLException {

Added: db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement42.java?rev=1444960&view=auto
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement42.java (added)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement42.java Mon
Feb 11 20:59:19 2013
@@ -0,0 +1,123 @@
+/*
+ 
+   Derby - Class org.apache.derby.client.am.CallableStatement42
+ 
+   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;
+import org.apache.derby.shared.common.reference.SQLState;
+
+
+public class CallableStatement42 extends CallableStatement40
+{    
+    /**
+     * Calls the superclass constructor and passes the parameters
+     *
+     * @param agent       The instance of NetAgent associated with this
+     *                    CallableStatement object.
+     * @param connection  The connection object associated with this
+     *                    PreparedStatement Object.
+     * @param sql         A String object that is the SQL statement to be sent 
+     *                    to the database.
+     * @param type        One of the ResultSet type constants
+     * @param concurrency One of the ResultSet concurrency constants
+     * @param holdability One of the ResultSet holdability constants
+     * @param cpc         The PooledConnection object that will be used to 
+     *                    notify the PooledConnection reference of the Error 
+     *                    Occurred and the Close events.
+     * @throws SqlException
+     */
+    public CallableStatement42(Agent agent,
+        Connection connection,
+        String sql,
+        int type, int concurrency, int holdability,
+        ClientPooledConnection cpc) throws SqlException {
+        super(agent, connection, sql, type, concurrency, holdability,cpc);        
+    }
+    
+    public  void registerOutParameter( int parameterIndex, SQLType sqlType )
+        throws SQLException
+    {
+        try
+        {
+            synchronized (connection_) {
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceEntry( this, "registerOutParameter", parameterIndex,
sqlType );
+                }
+                checkForClosedStatement();
+                registerOutParameter( parameterIndex, Utils42.getTypeAsInt( agent_, sqlType
) );
+            }
+        }
+        catch ( SqlException se )  { throw se.getSQLException(); }
+    }
+
+    public  void registerOutParameter( int parameterIndex, SQLType sqlType, int scale )
+        throws SQLException
+    {
+        try
+        {
+            synchronized (connection_) {
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceEntry( this, "registerOutParameter", parameterIndex,
sqlType, scale );
+                }
+                checkForClosedStatement();
+                registerOutParameter( parameterIndex, Utils42.getTypeAsInt( agent_, sqlType
), scale );
+            }
+        }
+        catch ( SqlException se )  { throw se.getSQLException(); }
+    }
+    
+    public  void registerOutParameter( int parameterIndex, SQLType sqlType, String typeName
)
+        throws SQLException
+    {
+        try
+        {
+            synchronized (connection_) {
+                if (agent_.loggingEnabled()) {
+                    agent_.logWriter_.traceEntry( this, "registerOutParameter", parameterIndex,
sqlType, typeName );
+                }
+                checkForClosedStatement();
+                registerOutParameter( parameterIndex, Utils42.getTypeAsInt(agent_, sqlType
), typeName );
+            }
+        }
+        catch ( SqlException se )  { throw se.getSQLException(); }
+    }
+    
+    public  void registerOutParameter( String parameterName, SQLType sqlType )
+        throws SQLException
+    {
+        throw jdbcMethodNotImplemented();
+    }
+    
+    public  void registerOutParameter( String parameterName, SQLType sqlType, int scale )
+        throws SQLException
+    {
+        throw jdbcMethodNotImplemented();
+    }
+    
+    public  void registerOutParameter( String parameterName,  SQLType sqlType, String typeName
)
+        throws SQLException
+    {
+        throw jdbcMethodNotImplemented();
+    }
+
+}

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

Added: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement42.java?rev=1444960&view=auto
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement42.java
(added)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement42.java
Mon Feb 11 20:59:19 2013
@@ -0,0 +1,91 @@
+/*
+
+   Derby - Class org.apache.derby.client.am.LogicalCallableStatement42
+
+   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 specific wrapper class for a Derby physical callable statement.
+ *
+ * @see LogicalCallableStatement
+ * @see #isClosed
+ */
+public class LogicalCallableStatement42 extends LogicalCallableStatement40
+{
+    /**
+     * Creates a new logical callable statement.
+     *
+     * @param physicalCs 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 LogicalCallableStatement42(java.sql.CallableStatement physicalCs,
+                                      StatementKey stmtKey,
+                                      StatementCacheInteractor cacheInteractor){
+        super(physicalCs, stmtKey, cacheInteractor);
+    }
+
+    ////////////////////////////////////////////////////////////////////
+    //
+    // INTRODUCED BY JDBC 4.2 IN JAVA 8
+    //
+    ////////////////////////////////////////////////////////////////////
+    
+    public  void registerOutParameter( int parameterIndex, SQLType sqlType )
+        throws SQLException
+    {
+        ((CallableStatement42)getPhysCs()).registerOutParameter( parameterIndex, sqlType
);
+    }
+
+    public  void registerOutParameter( int parameterIndex, SQLType sqlType, int scale )
+        throws SQLException
+    {
+        ((CallableStatement42)getPhysCs()).registerOutParameter( parameterIndex, sqlType,
scale );
+    }
+    
+    public  void registerOutParameter( int parameterIndex, SQLType sqlType, String typeName
)
+        throws SQLException
+    {
+        ((CallableStatement42)getPhysCs()).registerOutParameter( parameterIndex, sqlType,
typeName );
+    }
+    
+    public  void registerOutParameter( String parameterName, SQLType sqlType )
+        throws SQLException
+    {
+        ((CallableStatement42)getPhysCs()).registerOutParameter( parameterName, sqlType );
+    }
+    
+    public  void registerOutParameter( String parameterName, SQLType sqlType, int scale )
+        throws SQLException
+    {
+        ((CallableStatement42)getPhysCs()).registerOutParameter( parameterName, sqlType,
scale );
+    }
+    
+    public  void registerOutParameter( String parameterName,  SQLType sqlType, String typeName
)
+        throws SQLException
+    {
+        ((CallableStatement42)getPhysCs()).registerOutParameter( parameterName, sqlType,
typeName );
+    }
+
+}

Propchange: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement42.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=1444960&r1=1444959&r2=1444960&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
Mon Feb 11 20:59:19 2013
@@ -25,7 +25,11 @@ import org.apache.derby.client.am.SqlExc
 
 import org.apache.derby.client.ClientPooledConnection;
 import org.apache.derby.client.am.Agent;
+import org.apache.derby.client.am.CallableStatement;
+import org.apache.derby.client.am.CallableStatement42;
 import org.apache.derby.client.am.Cursor;
+import org.apache.derby.client.am.LogicalCallableStatement;
+import org.apache.derby.client.am.LogicalCallableStatement42;
 import org.apache.derby.client.am.LogicalPreparedStatement;
 import org.apache.derby.client.am.LogicalPreparedStatement42;
 import org.apache.derby.client.am.PreparedStatement;
@@ -103,6 +107,25 @@ public class ClientJDBCObjectFactoryImpl
                 actualResultSetHoldability);
     }
 
+    /** return a CallableStatement */
+    public CallableStatement newCallableStatement(Agent agent,
+            org.apache.derby.client.am.Connection connection,
+            String sql,int type,int concurrency,
+            int holdability,ClientPooledConnection cpc) throws SqlException {
+        return new CallableStatement42(agent,connection,sql,type,concurrency,
+                holdability,cpc);
+    }
+
+    /**
+     * Returns a new logical callable statement object.
+     */
+    public LogicalCallableStatement newLogicalCallableStatement(
+            java.sql.CallableStatement cs,
+            StatementKey stmtKey,
+            StatementCacheInteractor cacheInteractor) {
+        return new LogicalCallableStatement42(cs, stmtKey, cacheInteractor);
+    }
+    
 }
 
     

Added: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement42.java?rev=1444960&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement42.java
(added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement42.java
Mon Feb 11 20:59:19 2013
@@ -0,0 +1,71 @@
+/*
+ 
+   Derby - Class org.apache.derby.iapi.jdbc.BrokeredCallableStatement42
+ 
+   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 BrokeredCallableStatement42 extends BrokeredCallableStatement40
+{
+    public BrokeredCallableStatement42( BrokeredStatementControl control, String sql )
+        throws SQLException
+    {
+        super(control, sql);
+    }
+    
+    public  void registerOutParameter( int parameterIndex, SQLType sqlType )
+        throws SQLException
+    {
+        getCallableStatement().registerOutParameter( parameterIndex, sqlType );
+    }
+    
+    public  void registerOutParameter( int parameterIndex, SQLType sqlType, int scale )
+        throws SQLException
+    {
+        getCallableStatement().registerOutParameter( parameterIndex, sqlType, scale );
+    }
+    
+    public  void registerOutParameter( int parameterIndex, SQLType sqlType, String typeName
)
+        throws SQLException
+    {
+        getCallableStatement().registerOutParameter( parameterIndex, sqlType, typeName );
+    }
+    
+    public  void registerOutParameter( String parameterName, SQLType sqlType )
+        throws SQLException
+    {
+        getCallableStatement().registerOutParameter( parameterName, sqlType );
+    }
+    
+    public  void registerOutParameter( String parameterName, SQLType sqlType, int scale )
+        throws SQLException
+    {
+        getCallableStatement().registerOutParameter( parameterName, sqlType, scale );
+    }
+    
+    public  void registerOutParameter( String parameterName,  SQLType sqlType, String typeName
)
+        throws SQLException
+    {
+        getCallableStatement().registerOutParameter( parameterName, sqlType, typeName );
+    }
+    
+}

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

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=1444960&r1=1444959&r2=1444960&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 Mon
Feb 11 20:59:19 2013
@@ -271,7 +271,7 @@ public class BrokeredConnection40
             throw sqle;
         }
     }
-    public final BrokeredCallableStatement newBrokeredStatement(BrokeredStatementControl
statementControl, String sql) throws SQLException {
+    public BrokeredCallableStatement newBrokeredStatement(BrokeredStatementControl statementControl,
String sql) throws SQLException {
         try {
             return new BrokeredCallableStatement40(statementControl, sql);
         } catch (SQLException sqle) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection42.java?rev=1444960&r1=1444959&r2=1444960&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection42.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection42.java Mon
Feb 11 20:59:19 2013
@@ -43,4 +43,13 @@ public class BrokeredConnection42
             throw sqle;
         }
     }
+    
+    public BrokeredCallableStatement newBrokeredStatement(BrokeredStatementControl statementControl,
String sql) throws SQLException {
+        try {
+            return new BrokeredCallableStatement42(statementControl, sql);
+        } catch (SQLException sqle) {
+            notifyException(sqle);
+            throw sqle;
+        }
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement.java?rev=1444960&r1=1444959&r2=1444960&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement.java
Mon Feb 11 20:59:19 2013
@@ -210,7 +210,7 @@ public class EmbedCallableStatement exte
 	/**
 	 * JDBC 2.0
 	 *
-	 * Registers the designated output parameter
+	 * Derby ignores the typeName argument because UDTs don't need it.
 	 *
 	 * @exception SQLException if a database-access error occurs.
 	 */
@@ -218,7 +218,7 @@ public class EmbedCallableStatement exte
  									 String typeName) 
  		 throws SQLException
  	{
- 		throw Util.notImplemented("registerOutParameter");
+ 		registerOutParameter( parameterIndex, sqlType );
  	}
  		 
  

Added: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement42.java?rev=1444960&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement42.java
(added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement42.java
Mon Feb 11 20:59:19 2013
@@ -0,0 +1,78 @@
+/*
+
+   Derby - Class org.apache.derby.impl.jdbc.EmbedCallableStatement42
+
+   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.SQLException;
+import java.sql.SQLType;
+import org.apache.derby.iapi.reference.SQLState;
+
+public class EmbedCallableStatement42 extends EmbedCallableStatement40
+{
+        
+    /** Creates a new instance of EmbedCallableStatement42 */
+    public EmbedCallableStatement42(EmbedConnection conn, String sql,
+        int resultSetType,
+        int resultSetConcurrency,
+        int resultSetHoldability) throws SQLException{
+        super(conn, sql, resultSetType, resultSetConcurrency, resultSetHoldability);    

+    }
+
+    public  void registerOutParameter( int parameterIndex, SQLType sqlType )
+        throws SQLException
+    {
+        checkStatus();
+        registerOutParameter( parameterIndex, Util42.getTypeAsInt( this, sqlType ) );
+    }
+    
+    public  void registerOutParameter( int parameterIndex, SQLType sqlType, int scale )
+        throws SQLException
+    {
+        checkStatus();
+        registerOutParameter( parameterIndex, Util42.getTypeAsInt( this, sqlType ), scale
);
+    }
+    
+    public  void registerOutParameter( int parameterIndex, SQLType sqlType, String typeName
)
+        throws SQLException
+    {
+        checkStatus();
+        registerOutParameter( parameterIndex, Util42.getTypeAsInt( this, sqlType ), typeName
);
+    }
+    
+    public  void registerOutParameter( String parameterName, SQLType sqlType )
+        throws SQLException
+    {
+        throw Util.notImplemented();
+    }
+    
+    public  void registerOutParameter( String parameterName, SQLType sqlType, int scale )
+        throws SQLException
+    {
+        throw Util.notImplemented();
+    }
+    
+    public  void registerOutParameter( String parameterName,  SQLType sqlType, String typeName
)
+        throws SQLException
+    {
+        throw Util.notImplemented();
+    }
+    
+}

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

Modified: 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=1444960&r1=1444959&r2=1444960&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver42.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver42.java Mon Feb 11 20:59:19
2013
@@ -21,6 +21,7 @@
 
 package org.apache.derby.jdbc;
 
+import java.sql.CallableStatement;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 
@@ -32,6 +33,7 @@ import org.apache.derby.iapi.sql.ResultS
 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.EmbedCallableStatement42;
 import org.apache.derby.impl.jdbc.EmbedConnection;
 import org.apache.derby.impl.jdbc.EmbedResultSet;
 import org.apache.derby.impl.jdbc.EmbedResultSet42;
@@ -85,4 +87,18 @@ public class Driver42 extends Driver40
         return new EmbedResultSet42( conn, results, forMetaData, statement, isAtomic );
     }
 
+    public CallableStatement newEmbedCallableStatement(
+        EmbedConnection conn,
+        String stmt,
+        int resultSetType,
+        int resultSetConcurrency,
+        int resultSetHoldability)
+        throws SQLException {
+        return new EmbedCallableStatement42(conn,
+            stmt,
+            resultSetType,
+            resultSetConcurrency,
+            resultSetHoldability);
+    }
+
 }

Modified: 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=1444960&r1=1444959&r2=1444960&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest42.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest42.java
Mon Feb 11 20:59:19 2013
@@ -21,7 +21,9 @@
 package org.apache.derbyTesting.functionTests.tests.jdbc4;
 
 import java.math.BigDecimal;
+import java.io.Serializable;
 import java.sql.Blob;
+import java.sql.CallableStatement;
 import java.sql.Clob;
 import java.sql.Connection;
 import java.sql.Date;
@@ -52,6 +54,8 @@ public class PreparedStatementTest42 ext
     //
     //////////////////////////////////////////////////////////
 
+    private static  final   String  UNIMPLEMENTED_FEATURE = "0A000";
+
     //
     // If any of these becomes a legal Derby type, remove it from this table and put a corresponding
line
     // into _columnDescs.
@@ -93,8 +97,8 @@ public class PreparedStatementTest42 ext
         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.REAL, "real", new Float( 0.0F ), new Float( 1F ), null ),
+        new ColumnDesc( JDBCType.SMALLINT, "smallint", new Integer( 0 ), new Integer( 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 ),
@@ -176,18 +180,14 @@ public class PreparedStatementTest42 ext
     {
         Connection conn = getConnection();
 
+        setupPrice( conn );
         makeTable( conn );
         populateTable( conn );
         vetTableContents( conn );
         updateColumns( 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" );
@@ -389,12 +389,243 @@ public class PreparedStatementTest42 ext
         selectPS.close();
     }
 
+    /**
+     * <p>
+     * Test the CallableStatement.registerObject() overloads added by JDBC 4.2.
+     * </p>
+     */
+    public  void    test_02_registerObject() throws Exception
+    {
+        Connection conn = getConnection();
+
+        registerObjectTest( conn );
+    }
+    public  static  void    registerObjectTest( Connection conn ) throws Exception
+    {
+        createSchemaObjects( conn );
+        vetProc( conn );
+    }
+    private static void    createSchemaObjects( Connection conn ) throws Exception
+    {
+        setupPrice( conn );
+        createProc( conn );
+    }
+    private static void    createProc( Connection conn ) throws Exception
+    {
+        StringBuilder   buffer = new StringBuilder();
+
+        buffer.append( "create procedure unpackAllTypes( in valueIdx int" );
+        
+        for ( int i = 0; i < _columnDescs.length; i++ )
+        {
+            ColumnDesc  cd = _columnDescs[ i ];
+            String  parameterName = "param" + (i+1);
+            String  parameterType = cd.sqlType;
+            buffer.append( ", out " + parameterName + " " + parameterType );
+        }
+        
+        buffer.append( " ) language java parameter style java no sql\n" );
+        buffer.append( "external name 'org.apache.derbyTesting.functionTests.tests.jdbc4.PreparedStatementTest42.unpackAllTypes'"
);
+
+        String  sqlText = buffer.toString();
+        println( sqlText );
+
+        conn.prepareStatement( sqlText ).execute();
+    }
+    private static void    vetProc( Connection conn ) throws Exception
+    {
+        StringBuilder   buffer = new StringBuilder();
+        buffer.append( "call unpackAllTypes( ?" );
+        for ( int i = 0; i < _columnDescs.length; i++ ) { buffer.append( ", ?" ); }
+        buffer.append( " )" );
+        String  sqlText = buffer.toString();
+        println( sqlText );
+
+        CallableStatement   cs = conn.prepareCall( sqlText );
+        int     valueIdx;
+        int     param;
+
+        // registerOutParameter( int, SQLType )
+        valueIdx = 0;
+        param = 1;
+        cs.setInt( param++, valueIdx );
+        for ( int i = 0; i < _columnDescs.length; i++ )
+        {
+            cs.registerOutParameter( param++, _columnDescs[ i ].jdbcType );
+        }
+        cs.execute();
+        vetCS( cs, valueIdx );
+
+        // registerOutParameter( int, SQLType, int )
+        valueIdx = 1;
+        param = 1;
+        cs.setInt( param++, valueIdx );
+        for ( int i = 0; i < _columnDescs.length; i++ )
+        {
+            cs.registerOutParameter( param++, _columnDescs[ i ].jdbcType, 0 );
+        }
+        cs.execute();
+        vetCS( cs, valueIdx );
+
+        // registerOutParameter( int, SQLType, String )
+        valueIdx = 0;
+        param = 1;
+        cs.setInt( param++, valueIdx );
+        for ( int i = 0; i < _columnDescs.length; i++ )
+        {
+            cs.registerOutParameter( param++, _columnDescs[ i ].jdbcType, "foo" );
+        }
+        cs.execute();
+        vetCS( cs, valueIdx );
+
+        // registerOutParameter( String, SQLType )
+        try {
+            cs.registerOutParameter( "param1", _columnDescs[ 0 ].jdbcType );
+            fail( "Expected unimplemented feature." );
+        }
+        catch (SQLException se)
+        {
+            assertSQLState( UNIMPLEMENTED_FEATURE, se );
+        }
+
+        // registerOutParameter( String, SQLType, int )
+        try {
+            cs.registerOutParameter( "param1", _columnDescs[ 0 ].jdbcType, 0 );
+            fail( "Expected unimplemented feature." );
+        }
+        catch (SQLException se)
+        {
+            assertSQLState( UNIMPLEMENTED_FEATURE, se );
+        }
+
+        // registerOutParameter( String, SQLType, String )
+        try {
+            cs.registerOutParameter( "param1", _columnDescs[ 0 ].jdbcType, "foo" );
+            fail( "Expected unimplemented feature." );
+        }
+        catch (SQLException se)
+        {
+            assertSQLState( UNIMPLEMENTED_FEATURE, se );
+        }
+    }
+    private  static void    vetCS( CallableStatement cs, int valueIdx )
+        throws Exception
+    {
+        int     idx = 0;
+        int     colIdx = 2;
+
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+        assertObjectEquals( _columnDescs[ idx++ ].values[ valueIdx ], cs.getObject( colIdx++
) );
+    }
+
+
+    //////////////////////////////////////////////////////////
+    //
+    // SQL ROUTINES
+    //
+    //////////////////////////////////////////////////////////
+
+    public  static  void    unpackAllTypes
+        (
+         int valueIdx,
+         Long[]    bigintValue,
+         Blob[]   blobValue,
+         Boolean[] booleanValue,
+         String[]  charValue,
+         byte[][]  binaryValue,
+         Clob[]    clobValue,
+         Date[]    dateValue,
+         BigDecimal[]  decimalValue,
+         Double[]  doubleValue,
+         Double[]  floatValue,
+         Integer[] intValue,
+         String[]  longVarcharValue,
+         byte[][]  longVarbinaryValue,
+         BigDecimal[]  numericValue,
+         Float[]   realValue,
+         Integer[]   smallintValue,
+         Time[]    timeValue,
+         Timestamp[]  timestampValue,
+         Price[]   priceValue,
+         String[]  varcharValue,
+         byte[][]  varbinaryValue
+         )
+    {
+        int     colIdx = 0;
+        
+        bigintValue[ 0 ] = (Long) _columnDescs[ colIdx++ ].values[ valueIdx ];
+        blobValue[ 0 ] = (Blob) _columnDescs[ colIdx++ ].values[ valueIdx ];
+        booleanValue[ 0 ] = (Boolean) _columnDescs[ colIdx++ ].values[ valueIdx ];
+        charValue[ 0 ] = (String) _columnDescs[ colIdx++ ].values[ valueIdx ];
+        binaryValue[ 0 ] = (byte[]) _columnDescs[ colIdx++ ].values[ valueIdx ];
+        clobValue[ 0 ] = (Clob) _columnDescs[ colIdx++ ].values[ valueIdx ];
+        dateValue[ 0 ] = (Date) _columnDescs[ colIdx++ ].values[ valueIdx ];
+        decimalValue[ 0 ] = (BigDecimal) _columnDescs[ colIdx++ ].values[ valueIdx ];
+        doubleValue[ 0 ] = (Double) _columnDescs[ colIdx++ ].values[ valueIdx ];
+        floatValue[ 0 ] = (Double) _columnDescs[ colIdx++ ].values[ valueIdx ];
+        intValue[ 0 ] = (Integer) _columnDescs[ colIdx++ ].values[ valueIdx ];
+        longVarcharValue[ 0 ] = (String) _columnDescs[ colIdx++ ].values[ valueIdx ];
+        longVarbinaryValue[ 0 ] = (byte[]) _columnDescs[ colIdx++ ].values[ valueIdx ];
+        numericValue[ 0 ] = (BigDecimal) _columnDescs[ colIdx++ ].values[ valueIdx ];
+        realValue[ 0 ] = (Float) _columnDescs[ colIdx++ ].values[ valueIdx ];
+        smallintValue[ 0 ] = (Integer) _columnDescs[ colIdx++ ].values[ valueIdx ];
+        timeValue[ 0 ] = (Time) _columnDescs[ colIdx++ ].values[ valueIdx ];
+        timestampValue[ 0 ] = (Timestamp) _columnDescs[ colIdx++ ].values[ valueIdx ];
+        priceValue[ 0 ] = (Price) _columnDescs[ colIdx++ ].values[ valueIdx ];
+        varcharValue[ 0 ] = (String) _columnDescs[ colIdx++ ].values[ valueIdx ];
+        varbinaryValue[ 0 ] = (byte[]) _columnDescs[ colIdx++ ].values[ valueIdx ];
+    }
+
     //////////////////////////////////////////////////////////
     //
     // MINIONS
     //
     //////////////////////////////////////////////////////////
 
+    private static void setupPrice( Connection conn ) throws Exception
+    {
+        if ( !aliasExists( conn, "PRICE" ) )
+        {
+            conn.prepareStatement
+                (
+                 "create type Price external name 'org.apache.derbyTesting.functionTests.tests.lang.Price'
language java"
+                 ).execute();
+        }
+    }
+    private static  boolean aliasExists( Connection conn, String aliasName ) throws Exception
+    {
+        PreparedStatement   ps = conn.prepareStatement( "select count(*) from sys.sysaliases
where alias = ?" );
+        ps.setString( 1, aliasName );
+        ResultSet   rs = ps.executeQuery();
+        rs.next();
+
+        int retval = rs.getInt( 1 );
+
+        rs.close();
+        ps.close();
+
+        return (retval > 0);
+    }
+    
     private  static  Blob    makeBlob( String contents )
     {
         return new HarmonySerialBlob( makeBinary( contents ) );
@@ -422,7 +653,7 @@ public class PreparedStatementTest42 ext
         return Price.makePrice( new BigDecimal( raw ) );
     }
 
-    private void    assertObjectEquals( Object expected, Object actual ) throws Exception
+    public static void    assertObjectEquals( Object expected, Object actual ) throws Exception
     {
         if ( expected == null )
         {
@@ -439,7 +670,7 @@ public class PreparedStatementTest42 ext
         else if ( expected instanceof byte[] ) { compareBytes( (byte[]) expected, (byte[])
actual ); }
         else { assertEquals( expected.toString(), actual.toString() ); }
     }
-    private void  compareBytes( byte[] left, byte[] right )
+    private static void  compareBytes( byte[] left, byte[] right )
         throws Exception
     {
         int count = left.length;

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/XA40Test.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/XA40Test.java?rev=1444960&r1=1444959&r2=1444960&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/XA40Test.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/XA40Test.java
Mon Feb 11 20:59:19 2013
@@ -26,6 +26,7 @@ import org.apache.derbyTesting.junit.Tes
 
 import junit.framework.*;
 
+import java.lang.reflect.Method;
 import java.sql.*;
 
 import javax.sql.XAConnection;
@@ -188,6 +189,22 @@ public class XA40Test extends BaseJDBCTe
     }
 
     /**
+     * <p>
+     * Test the JDBC 4.2 additions to brokered CallableStatements.
+     * </p>
+     */
+    public void test_registerOutParameter_jdbc4_2() throws Exception
+    {
+        if ( isJava8() )
+        {
+            Class<?>   klass = Class.forName( "org.apache.derbyTesting.functionTests.tests.jdbc4.PreparedStatementTest42"
);
+            Method  method = klass.getMethod( "registerObjectTest", new Class<?>[]
{ Connection.class } );
+
+            method.invoke( null, new Object[] { con } );
+        }
+    }
+
+    /**
      * Create test suite for XA40Test.
      */
     public static Test suite() {

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CallableTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CallableTest.java?rev=1444960&r1=1444959&r2=1444960&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CallableTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CallableTest.java
Mon Feb 11 20:59:19 2013
@@ -218,9 +218,6 @@ public class CallableTest extends BaseJD
             // Test that both requires DriverManager and BigDecimal
             suite.addTest
                 (new CallableTest("xtestNumericBoundariesProc"));
-            
-            suite.addTest
-                (new CallableTest("xtestRegUserDefOutParameterError"));
         }
 
 
@@ -589,27 +586,6 @@ public class CallableTest extends BaseJD
     }
 
     /**
-     * Tries to register a user-defined OUT parameter, which isn't supported
-     * and is expected to throw a "not implemented" exception.
-     * DERBY-1184 fixed the behavior in the Derby Network Client to throw an
-     * exception; however, DB2 Client behavior is incorrect, so the suite 
-     * excludes this test when run with DB2 Client.
-     * @throws SQLException 
-     */
-    public void xtestRegUserDefOutParameterError() throws SQLException
-    {
-        CallableStatement cs = prepareCall
-            ("? = call NO_IN_ONE_OUT_FUNC()");
-
-        try {
-            cs.registerOutParameter (1, java.sql.Types.INTEGER, "user-def");
-            fail("FAIL - Shouldn't reach here. Functionality not implemented.");
-        } catch (SQLException se) {
-            assertSQLState(NOT_IMPLEMENTED, se);
-        }
-    }
-
-    /**
      * Calls a SQL procedure that updates a long varbinary column.
      * Uses DriverManager, so this test requires JDBC 2 DriverManager support.
      * @throws SQLException 



Mime
View raw message