You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by rh...@apache.org on 2006/02/23 19:22:42 UTC
svn commit: r380187 [1/4] - in /db/derby/code/trunk/java:
client/org/apache/derby/client/ client/org/apache/derby/client/am/
client/org/apache/derby/client/net/ client/org/apache/derby/jdbc/
engine/org/apache/derby/impl/jdbc/ testing/org/apache/derbyTe...
Author: rhillegas
Date: Thu Feb 23 10:22:35 2006
New Revision: 380187
URL: http://svn.apache.org/viewcvs?rev=380187&view=rev
Log:
Narayanan's patch for DERBY-796: 1) implements JDBC4 LOB extensions, 2) refactors logic for creating JDBC4-specific implementations.
Added:
db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientJDBCObjectFactory.java (with props)
db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java (with props)
db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl40.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods_app.properties (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/aclob.txt (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/littleclob.txt (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/short.txt (with props)
Removed:
db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientJDBCObjectFactory.java
Modified:
db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/Blob.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/BlobOutputStream.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/ClobOutputStream.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement40.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/NetCallableStatement.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection40.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/NetPreparedStatement.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet40.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementReply.java
db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java
db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java
db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement40.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc4.properties
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestCallableStatementMethods.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnection.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods_app.properties
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestResultSetMethods.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/copyfiles.ant
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java Thu Feb 23 10:22:35 2006
@@ -20,11 +20,12 @@
package org.apache.derby.client;
import java.sql.SQLException;
-
-import org.apache.derby.client.am.SqlException;
-import org.apache.derby.client.net.NetLogWriter;
import org.apache.derby.jdbc.ClientDataSource;
+import org.apache.derby.jdbc.ClientDriver;
+import org.apache.derby.client.am.ClientJDBCObjectFactory;
import org.apache.derby.client.am.MessageId;
+import org.apache.derby.client.am.SqlException;
+import org.apache.derby.client.net.NetLogWriter;
import org.apache.derby.shared.common.reference.SQLState;
public class ClientPooledConnection implements javax.sql.PooledConnection {
@@ -60,14 +61,17 @@
user_ = user;
password_ = password;
listeners_ = new java.util.Vector();
-
- netPhysicalConnection_ = new org.apache.derby.client.net.NetConnection((NetLogWriter) logWriter_,
+
+ netPhysicalConnection_ = (org.apache.derby.client.net.NetConnection)
+ ClientDriver.getFactory().newNetConnection(
+ (NetLogWriter) logWriter_,
user,
password,
ds,
-1,
false);
- physicalConnection_ = netPhysicalConnection_;
+
+ physicalConnection_ = netPhysicalConnection_;
}
catch ( SqlException se )
{
@@ -83,8 +87,7 @@
String user,
String password,
int rmId) throws SQLException {
- try
- {
+ try {
logWriter_ = logWriter;
ds_ = ds;
user_ = user;
@@ -98,29 +101,29 @@
rmId,
true);
physicalConnection_ = netXAPhysicalConnection_;
- }
- catch ( SqlException se )
- {
+ } catch ( SqlException se ) {
throw se.getSQLException();
}
}
public ClientPooledConnection(ClientDataSource ds,
org.apache.derby.client.am.LogWriter logWriter) throws SQLException {
- try
- {
- logWriter_ = logWriter;
- ds_ = ds;
- listeners_ = new java.util.Vector();
- netPhysicalConnection_ = new org.apache.derby.client.net.NetConnection((NetLogWriter) logWriter_,
+ logWriter_ = logWriter;
+ ds_ = ds;
+ listeners_ = new java.util.Vector();
+ try {
+ netPhysicalConnection_ = (org.apache.derby.client.net.NetConnection)
+ ClientDriver.getFactory().newNetConnection(
+ (NetLogWriter) logWriter_,
null,
null,
ds,
-1,
false);
+
physicalConnection_ = netPhysicalConnection_;
}
- catch ( SqlException se )
+ catch (SqlException se)
{
throw se.getSQLException();
}
@@ -184,7 +187,7 @@
}
return logicalConnection_;
}
- catch ( SqlException se )
+ catch (SqlException se)
{
throw se.getSQLException();
}
@@ -245,6 +248,3 @@
logicalConnection_ = null;
}
}
-
-
-
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Blob.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/Blob.java?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Blob.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Blob.java Thu Feb 23 10:22:35 2006
@@ -267,15 +267,33 @@
public int setBytesX(long pos, byte[] bytes, int offset, int len) throws SqlException {
int length = 0;
- if ((int) pos <= 0) {
+
+ /*
+ Check if position is less than 0 and if true
+ raise an exception
+ */
+
+ if (pos <= 0L) {
+ throw new SqlException(agent_.logWriter_,
+ new MessageId(SQLState.BLOB_BAD_POSITION), new Long(pos));
+ }
+
+ /*
+ Currently only 2G-1 bytes can be inserted in a
+ single Blob column hence check corresponding position
+ value
+ */
+
+ if (pos >= Integer.MAX_VALUE) {
throw new SqlException(agent_.logWriter_,
- new MessageId(SQLState.BLOB_BAD_POSITION), new Long(pos));
+ new MessageId(SQLState.BLOB_POSITION_TOO_LARGE), new Long(pos));
}
- if ( pos > binaryString_.length - dataOffset_) {
- throw new SqlException(agent_.logWriter_,
- new MessageId(SQLState.BLOB_POSITION_TOO_LARGE), new Long(pos));
+ if (pos - 1 > binaryString_.length - dataOffset_) {
+ throw new SqlException(agent_.logWriter_,
+ new MessageId(SQLState.BLOB_POSITION_TOO_LARGE), new Long(pos));
}
+
if ((offset < 0) || offset > bytes.length )
{
throw new SqlException(agent_.logWriter_,
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/BlobOutputStream.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/BlobOutputStream.java?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/BlobOutputStream.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/BlobOutputStream.java Thu Feb 23 10:22:35 2006
@@ -28,7 +28,12 @@
public BlobOutputStream(Blob blob, long offset) {
blob_ = blob;
offset_ = offset;
- if (offset_ > (blob_.binaryString_.length - blob_.dataOffset_)) {
+
+ /*
+ offset_=1 while blob_.binaryString_.length - blob_.dataOffset_ = 0
+ for a empty Blob hence check for offset_-1
+ */
+ if ((offset_-1) > (blob_.binaryString_.length - blob_.dataOffset_)) {
throw new IndexOutOfBoundsException();
}
}
Added: db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientJDBCObjectFactory.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientJDBCObjectFactory.java?rev=380187&view=auto
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientJDBCObjectFactory.java (added)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientJDBCObjectFactory.java Thu Feb 23 10:22:35 2006
@@ -0,0 +1,155 @@
+/*
+
+ Derby - Class org.apache.derby.client.am.ClientJDBCObjectFactory
+
+ Copyright (c) 2005,2006 The Apache Software Foundation or its licensors, where applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+package org.apache.derby.client.am;
+
+import java.rmi.UnexpectedException;
+import org.apache.derby.client.ClientPooledConnection;
+import org.apache.derby.jdbc.ClientDataSource;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ *
+ * The methods of this interface are used to return JDBC interface
+ * implementations to the user depending on the JDBC version supported
+ * by the jdk
+ *
+ */
+
+public interface ClientJDBCObjectFactory {
+
+ /**
+ * This method is used to return an instance of
+ * ClientPooledConnection (or ClientPooledConnection40) class which
+ * implements javax.sql.PooledConnection
+ */
+ ClientPooledConnection newClientPooledConnection(ClientDataSource ds,
+ LogWriter logWriter,String user,String password)
+ throws SQLException;
+
+ /**
+ * This method is used to return an instance of
+ * ClientPooledConnection(or ClientPooledConnection40) class which
+ * implements javax.sql.PooledConnection
+ */
+ ClientPooledConnection newClientPooledConnection(ClientDataSource ds,
+ LogWriter logWriter,String user,String password,int rmId)
+ throws SQLException;
+
+ /**
+ * This method returns an instance of CallableStatement
+ * (or CallableStatement40) class which implements
+ * java.sql.CallableStatement
+ */
+ CallableStatement newCallableStatement(Agent agent,
+ org.apache.derby.client.am.Connection connection, String sql,
+ int type,int concurrency,int holdability) throws SqlException;
+
+ /**
+ * This method returns an instance of PreparedStatement
+ * (or PreparedStatement40) which implements java.sql.PreparedStatement
+ */
+ PreparedStatement newPreparedStatement(Agent agent,
+ org.apache.derby.client.am.Connection connection,
+ String sql,Section section) throws SqlException;
+
+ /**
+ * This method returns an instance of PreparedStatement
+ * (or PreparedStatement40) which implements java.sql.PreparedStatement
+ */
+ PreparedStatement newPreparedStatement(Agent agent,
+ org.apache.derby.client.am.Connection connection,String sql,
+ int type,int concurrency,int holdability,int autoGeneratedKeys,
+ String [] columnNames) throws SqlException;
+
+ /**
+ * This method returns an instance of NetConnection (or NetConnection40) class
+ * which extends from org.apache.derby.client.am.Connection
+ * this implements the java.sql.Connection interface
+ */
+ org.apache.derby.client.am.Connection newNetConnection(
+ LogWriter netLogWriter,
+ String databaseName,java.util.Properties properties)
+ throws SqlException;
+
+ /**
+ * This method returns an instance of NetConnection (or NetConnection40) class
+ * which extends from org.apache.derby.client.am.Connection
+ * this implements the java.sql.Connection interface
+ */
+ org.apache.derby.client.am.Connection newNetConnection(
+ LogWriter netLogWriter,
+ org.apache.derby.jdbc.ClientDataSource clientDataSource,String user,
+ String password) throws SqlException;
+
+ /**
+ * This method returns an instance of NetConnection (or NetConnection40)
+ * class which extends from org.apache.derby.client.am.Connection
+ * this implements the java.sql.Connection interface
+ */
+ org.apache.derby.client.am.Connection newNetConnection(
+ LogWriter netLogWriter,
+ int driverManagerLoginTimeout,String serverName,
+ int portNumber,String databaseName,java.util.Properties properties)
+ throws SqlException;
+
+ /**
+ * This method returns an instance of NetConnection (or NetConnection40)
+ * class which extends from org.apache.derby.client.am.Connection
+ * this implements the java.sql.Connection interface
+ */
+ org.apache.derby.client.am.Connection newNetConnection(
+ LogWriter netLogWriter,
+ String user,String password,
+ org.apache.derby.jdbc.ClientDataSource dataSource,int rmId,
+ boolean isXAConn) throws SqlException;
+
+ /**
+ * This methos returns an instance of NetConnection
+ * (or NetConnection40) class which extends from
+ * org.apache.derby.client.am.Connection this implements the
+ * java.sql.Connection interface
+ */
+ org.apache.derby.client.am.Connection newNetConnection(
+ LogWriter netLogWriter,String ipaddr,
+ int portNumber,org.apache.derby.jdbc.ClientDataSource dataSource,
+ boolean isXAConn) throws SqlException;
+
+ /**
+ * This method returns an instance of NetResultSet(or NetResultSet40)
+ * which extends from org.apache.derby.client.am.ResultSet
+ * which implements java.sql.ResultSet
+ */
+ ResultSet newNetResultSet(Agent netAgent,MaterialStatement netStatement,
+ Cursor cursor,int sqlcsrhld,int qryattscr,int qryattsns,
+ int qryattset,long qryinsid,int actualResultSetType,
+ int actualResultSetConcurrency,int actualResultSetHoldability)
+ throws SqlException;
+
+ /**
+ * This method provides an instance of NetDatabaseMetaData
+ * (or NetDatabaseMetaData40) which extends from
+ * org.apache.derby.client.am.DatabaseMetaData which implements
+ * java.sql.DatabaseMetaData
+ */
+ DatabaseMetaData newNetDatabaseMetaData(Agent netAgent,
+ org.apache.derby.client.am.Connection netConnection);
+}
Propchange: db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientJDBCObjectFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ClobOutputStream.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/ClobOutputStream.java?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ClobOutputStream.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ClobOutputStream.java Thu Feb 23 10:22:35 2006
@@ -28,7 +28,13 @@
public ClobOutputStream(Clob clob, long offset) throws SqlException {
clob_ = clob;
offset_ = offset;
- if (offset_ > clob_.sqlLength_) {
+
+ /*
+ offset_ starts from 1 while sqlLenth_=0
+ in the case of a empty Clob hence check from
+ offset_-1
+ */
+ if ((offset_-1) > clob_.sqlLength_) {
throw new IndexOutOfBoundsException();
}
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java Thu Feb 23 10:22:35 2006
@@ -27,7 +27,7 @@
import org.apache.derby.iapi.services.info.ProductGenusNames;
import org.apache.derby.iapi.services.info.ProductVersionHolder;
-
+import org.apache.derby.shared.common.info.JVMInfo;
public class Configuration {
@@ -229,5 +229,18 @@
return myPVH;
}
+
+ /**
+ * Check to see if the jvm version is such that JDBC 4.0 is supported
+ */
+
+ public static boolean supportsJDBC40() {
+ if (JVMInfo.JDK_ID >= JVMInfo.J2SE_16) {
+ return true;
+ }
+ return false;
+ }
+
+
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java?rev=380187&r1=380186&r2=380187&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 23 10:22:35 2006
@@ -788,7 +788,7 @@
}
}
- public void setBinaryStreamX(int parameterIndex,
+ protected void setBinaryStreamX(int parameterIndex,
java.io.InputStream x,
int length) throws SqlException {
parameterIndex = checkSetterPreconditions(parameterIndex);
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement40.java?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement40.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement40.java Thu Feb 23 10:22:35 2006
@@ -53,7 +53,8 @@
throw SQLExceptionFactory.notImplemented ("setNString (int, String)");
}
- public void setNCharacterStream(int index, Reader value, long length) throws SQLException{
+ public void setNCharacterStream(int index, Reader value, long length)
+ throws SQLException{
throw SQLExceptionFactory.notImplemented ("setNCharacterStream " +
"(int,Reader,long)");
}
@@ -62,21 +63,73 @@
throw SQLExceptionFactory.notImplemented ("setNClob (int, NClob)");
}
+ /**
+ * Sets the designated parameter to a Reader object.
+ *
+ * @param parameterIndex index of the first parameter is 1, the second is 2, ...
+ * @param reader An object that contains the data to set the parameter value to.
+ * @param length the number of characters in the parameter data.
+ * @throws SQLException if parameterIndex does not correspond to a parameter
+ * marker in the SQL statement, or if the length specified is less than zero.
+ *
+ */
+
public void setClob(int parameterIndex, Reader reader, long length)
throws SQLException{
- throw SQLExceptionFactory.notImplemented ("setClob (int, Reader, long)");
+ synchronized (connection_) {
+ if (agent_.loggingEnabled()) {
+ agent_.logWriter_.traceEntry(this, "setClob",
+ parameterIndex, reader, new Long(length));
+ }
+ if(length > Integer.MAX_VALUE)
+ throw new SQLException("CLOB length exceeds maximum " +
+ "possible limit");
+ else
+ setInput(parameterIndex, new Clob(agent_, reader, (int)length));
+ }
}
+
+ /**
+ * Sets the designated parameter to a InputStream object.
+ *
+ * @param parameterIndex index of the first parameter is 1,
+ * the second is 2, ...
+ * @param inputStream An object that contains the data to set the parameter
+ * value to.
+ * @param length the number of bytes in the parameter data.
+ * @throws SQLException if parameterIndex does not correspond
+ * to a parameter marker in the SQL statement, if the length specified
+ * is less than zero or if the number of bytes in the inputstream does not match
+ * the specfied length.
+ *
+ */
public void setBlob(int parameterIndex, InputStream inputStream, long length)
throws SQLException{
- throw SQLExceptionFactory.notImplemented ("setBlob (int, InputStream, long)");
+ synchronized (connection_) {
+ if (agent_.loggingEnabled()) {
+ agent_.logWriter_.traceEntry(this, "setBlob", parameterIndex,
+ inputStream, new Long(length));
+ }
+ if(length > Integer.MAX_VALUE)
+ throw new SQLException("BLOB length exceeds maximum " +
+ "possible limit");
+ else {
+ try {
+ setBinaryStreamX(parameterIndex, inputStream, (int)length);
+ } catch(SqlException se){
+ throw se.getSQLException();
+ }
+ }
+ }
}
public void setNClob(int parameterIndex, Reader reader, long length)
throws SQLException{
throw SQLExceptionFactory.notImplemented ("setNClob (int, Reader, long)");
}
- public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException{
+ public void setSQLXML(int parameterIndex, SQLXML xmlObject)
+ throws SQLException{
throw SQLExceptionFactory.notImplemented ("setSQLXML (int, SQLXML)");
}
Added: db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java?rev=380187&view=auto
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java (added)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java Thu Feb 23 10:22:35 2006
@@ -0,0 +1,170 @@
+/*
+
+ Derby - Class org.apache.derby.client.net.ClientJDBCObjectFactoryImpl
+
+ Copyright (c) 2006 The Apache Software Foundation or its licensors, where applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+package org.apache.derby.client.net;
+
+import java.rmi.UnexpectedException;
+import java.sql.Connection;
+import java.sql.SQLException;
+import org.apache.derby.client.ClientPooledConnection;
+import org.apache.derby.client.am.CallableStatement;
+import org.apache.derby.client.am.ClientJDBCObjectFactory;
+import org.apache.derby.client.am.PreparedStatement;
+import org.apache.derby.client.am.Configuration;
+import org.apache.derby.client.am.LogWriter;
+import org.apache.derby.client.am.Agent;
+import org.apache.derby.client.am.Section;
+import org.apache.derby.client.am.SqlException;
+import org.apache.derby.client.am.Cursor;
+import org.apache.derby.jdbc.ClientDataSource;
+
+/**
+ * Implements the the ClientJDBCObjectFactory interface and returns the classes
+ * that implement the JDBC3.0/2.0 interfaces
+ * For Eg. newCallableStatement would return
+ * org.apache.derby.client.am.CallableStatement
+ */
+
+public class ClientJDBCObjectFactoryImpl implements ClientJDBCObjectFactory{
+ /**
+ * Returns an instance of org.apache.derby.client.ClientPooledConnection
+ */
+ public ClientPooledConnection newClientPooledConnection(ClientDataSource ds,
+ LogWriter logWriter,String user,
+ String password) throws SQLException {
+ return new ClientPooledConnection(ds,logWriter,user,password);
+ }
+ /**
+ * Returns an instance of org.apache.derby.client.ClientPooledConnection
+ */
+ public ClientPooledConnection newClientPooledConnection(ClientDataSource ds,
+ LogWriter logWriter,String user,
+ String password,int rmId) throws SQLException {
+ return new ClientPooledConnection(ds,logWriter,user,password,rmId);
+ }
+ /**
+ * Returns an instance of org.apache.derby.client.am.CallableStatement
+ */
+ public CallableStatement newCallableStatement(Agent agent,
+ org.apache.derby.client.am.Connection connection,
+ String sql,int type,int concurrency,
+ int holdability) throws SqlException {
+ return new CallableStatement(agent,connection,sql,type,
+ concurrency,holdability);
+ }
+
+ /**
+ * returns an instance of org.apache.derby.client.am.PreparedStatement
+ */
+ public PreparedStatement newPreparedStatement(Agent agent,
+ org.apache.derby.client.am.Connection connection,
+ String sql,Section section) throws SqlException {
+ return new PreparedStatement(agent,connection,sql,section);
+ }
+ /**
+ * returns an instance of org.apache.derby.client.am.PreparedStatement
+ */
+ public PreparedStatement newPreparedStatement(Agent agent,
+ org.apache.derby.client.am.Connection connection,
+ String sql,int type,int concurrency,int holdability,
+ int autoGeneratedKeys,String [] columnNames)
+ throws SqlException {
+ return new PreparedStatement(agent,connection,sql,type,concurrency,
+ holdability,autoGeneratedKeys,columnNames);
+ }
+ /**
+ * returns an instance of org.apache.derby.client.net.NetConnection
+ */
+ public org.apache.derby.client.am.Connection newNetConnection(
+ org.apache.derby.client.am.LogWriter netLogWriter,
+ String databaseName,java.util.Properties properties)
+ throws SqlException {
+ return (org.apache.derby.client.am.Connection)
+ (new NetConnection((NetLogWriter)netLogWriter,databaseName,properties));
+ }
+ /**
+ * returns an instance of org.apache.derby.client.net.NetConnection
+ */
+ public org.apache.derby.client.am.Connection newNetConnection(
+ org.apache.derby.client.am.LogWriter netLogWriter,
+ org.apache.derby.jdbc.ClientDataSource clientDataSource,
+ String user,String password) throws SqlException {
+ return (org.apache.derby.client.am.Connection)
+ (new NetConnection((NetLogWriter)netLogWriter,clientDataSource
+ ,user,password));
+ }
+ /**
+ * returns an instance of org.apache.derby.client.net.NetConnection
+ */
+ public org.apache.derby.client.am.Connection newNetConnection(
+ org.apache.derby.client.am.LogWriter netLogWriter,
+ int driverManagerLoginTimeout,String serverName,
+ int portNumber,String databaseName,
+ java.util.Properties properties) throws SqlException {
+ return (org.apache.derby.client.am.Connection)
+ (new NetConnection((NetLogWriter)netLogWriter,driverManagerLoginTimeout,
+ serverName,portNumber,databaseName,properties));
+ }
+ /**
+ * returns an instance of org.apache.derby.client.net.NetConnection
+ */
+ public org.apache.derby.client.am.Connection newNetConnection(
+ org.apache.derby.client.am.LogWriter netLogWriter,String user,
+ String password,
+ org.apache.derby.jdbc.ClientDataSource dataSource,
+ int rmId,boolean isXAConn) throws SqlException {
+ return (org.apache.derby.client.am.Connection)
+ (new NetConnection((NetLogWriter)netLogWriter,user,password,dataSource,rmId,
+ isXAConn));
+ }
+ /**
+ * returns an instance of org.apache.derby.client.net.NetConnection
+ */
+ public org.apache.derby.client.am.Connection newNetConnection(
+ org.apache.derby.client.am.LogWriter netLogWriter,
+ String ipaddr,int portNumber,
+ org.apache.derby.jdbc.ClientDataSource dataSource,
+ boolean isXAConn) throws SqlException {
+ return (org.apache.derby.client.am.Connection)
+ new NetConnection((NetLogWriter)netLogWriter,ipaddr,portNumber,dataSource,
+ isXAConn);
+ }
+ /**
+ * returns an instance of org.apache.derby.client.net.NetResultSet
+ */
+ public org.apache.derby.client.am.ResultSet newNetResultSet(Agent netAgent,
+ org.apache.derby.client.am.MaterialStatement netStatement,
+ Cursor cursor,int sqlcsrhld,int qryattscr,int qryattsns,
+ int qryattset,long qryinsid,int actualResultSetType,
+ int actualResultSetConcurrency,
+ int actualResultSetHoldability) throws SqlException {
+ return new NetResultSet((NetAgent)netAgent,(NetStatement)netStatement,cursor,sqlcsrhld,qryattscr,
+ qryattsns,qryattset,qryinsid,actualResultSetType,
+ actualResultSetConcurrency,actualResultSetHoldability);
+ }
+ /**
+ * returns an instance of org.apache.derby.client.net.NetDatabaseMetaData
+ */
+ public org.apache.derby.client.am.DatabaseMetaData newNetDatabaseMetaData(Agent netAgent,
+ org.apache.derby.client.am.Connection netConnection) {
+ return new NetDatabaseMetaData((NetAgent)netAgent,
+ (NetConnection)netConnection);
+ }
+}
Propchange: db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl40.java?rev=380187&view=auto
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl40.java (added)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl40.java Thu Feb 23 10:22:35 2006
@@ -0,0 +1,168 @@
+/*
+
+ Derby - Class org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40
+
+ Copyright (c) 2006 The Apache Software Foundation or its licensors, where applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+package org.apache.derby.client.net;
+
+import org.apache.derby.client.ClientPooledConnection;
+import org.apache.derby.client.ClientPooledConnection40;
+import org.apache.derby.client.am.CallableStatement;
+import org.apache.derby.client.am.CallableStatement40;
+import org.apache.derby.client.am.ClientJDBCObjectFactory;
+import org.apache.derby.client.am.PreparedStatement;
+import org.apache.derby.client.am.PreparedStatement40;
+import org.apache.derby.client.am.LogWriter;
+import org.apache.derby.client.am.Agent;
+import org.apache.derby.client.am.Section;
+import org.apache.derby.client.am.SqlException;
+import org.apache.derby.client.am.Cursor;
+import org.apache.derby.jdbc.ClientDataSource;
+import java.sql.SQLException;
+
+/**
+ * Implements the ClientJDBCObjectFactory interface
+ * and returns the JDBC4.0 specific classes
+ */
+public class ClientJDBCObjectFactoryImpl40 implements ClientJDBCObjectFactory{
+ /**
+ * Returns an instance of org.apache.derby.client.ClientPooledConnection40
+ */
+ public ClientPooledConnection newClientPooledConnection(ClientDataSource ds,
+ LogWriter logWriter,String user,
+ String password) throws SQLException {
+ return new ClientPooledConnection40(ds,logWriter,user,password);
+ }
+ /**
+ * Returns an instance of org.apache.derby.client.ClientPooledConnection40
+ */
+ public ClientPooledConnection newClientPooledConnection(ClientDataSource ds,
+ LogWriter logWriter,String user,
+ String password,int rmId) throws SQLException {
+ return new ClientPooledConnection40(ds,logWriter,user,password,rmId);
+ }
+ /**
+ * Returns an instance of org.apache.derby.client.am.CallableStatement40
+ */
+ public CallableStatement newCallableStatement(Agent agent,
+ org.apache.derby.client.am.Connection connection,
+ String sql,int type,int concurrency,
+ int holdability) throws SqlException {
+ return new CallableStatement40(agent,connection,sql,type,concurrency,
+ holdability);
+ }
+ /**
+ * Returns an instance of org.apache.derby.client.am.CallableStatement40
+ */
+ public PreparedStatement newPreparedStatement(Agent agent,
+ org.apache.derby.client.am.Connection connection,
+ String sql,Section section) throws SqlException {
+ return new PreparedStatement40(agent,connection,sql,section);
+ }
+ /**
+ * returns an instance of org.apache.derby.client.am.PreparedStatement40
+ */
+ public PreparedStatement newPreparedStatement(Agent agent,
+ org.apache.derby.client.am.Connection connection,
+ String sql,int type,int concurrency,
+ int holdability,int autoGeneratedKeys,
+ String [] columnNames) throws SqlException {
+ return new PreparedStatement40(agent,connection,sql,type,concurrency,
+ holdability,autoGeneratedKeys,columnNames);
+ }
+
+ /**
+ * returns an instance of org.apache.derby.client.net.NetConnection40
+ */
+ public org.apache.derby.client.am.Connection newNetConnection
+ (org.apache.derby.client.am.LogWriter netLogWriter,
+ String databaseName,java.util.Properties properties)
+ throws SqlException {
+ return (org.apache.derby.client.am.Connection)
+ (new NetConnection40((NetLogWriter)netLogWriter,databaseName,properties));
+ }
+ /**
+ * returns an instance of org.apache.derby.client.net.NetConnection40
+ */
+ public org.apache.derby.client.am.Connection newNetConnection
+ (org.apache.derby.client.am.LogWriter netLogWriter,
+ org.apache.derby.jdbc.ClientDataSource clientDataSource,
+ String user,String password) throws SqlException {
+ return (org.apache.derby.client.am.Connection)
+ (new NetConnection40((NetLogWriter)netLogWriter,clientDataSource,user,password));
+ }
+ /**
+ * returns an instance of org.apache.derby.client.net.NetConnection40
+ */
+ public org.apache.derby.client.am.Connection
+ newNetConnection(org.apache.derby.client.am.LogWriter netLogWriter,
+ int driverManagerLoginTimeout,String serverName,
+ int portNumber,String databaseName,
+ java.util.Properties properties) throws SqlException {
+ return (org.apache.derby.client.am.Connection)
+ (new NetConnection40((NetLogWriter)netLogWriter,driverManagerLoginTimeout,
+ serverName,portNumber,databaseName,properties));
+ }
+ /**
+ * returns an instance of org.apache.derby.client.net.NetConnection40
+ */
+ public org.apache.derby.client.am.Connection
+ newNetConnection(org.apache.derby.client.am.LogWriter netLogWriter,
+ String user,
+ String password,
+ org.apache.derby.jdbc.ClientDataSource dataSource,
+ int rmId,boolean isXAConn) throws SqlException {
+ return (org.apache.derby.client.am.Connection)
+ (new NetConnection40((NetLogWriter)netLogWriter,user,password,dataSource,
+ rmId,isXAConn));
+ }
+ /**
+ * returns an instance of org.apache.derby.client.net.NetConnection40
+ */
+ public org.apache.derby.client.am.Connection
+ newNetConnection(org.apache.derby.client.am.LogWriter netLogWriter,
+ String ipaddr,int portNumber,
+ org.apache.derby.jdbc.ClientDataSource dataSource,
+ boolean isXAConn) throws SqlException {
+ return (org.apache.derby.client.am.Connection)
+ (new NetConnection40((NetLogWriter)netLogWriter,ipaddr,portNumber,dataSource,
+ isXAConn));
+ }
+ /**
+ * returns an instance of org.apache.derby.client.net.NetResultSet
+ */
+ public org.apache.derby.client.am.ResultSet newNetResultSet(Agent netAgent,
+ org.apache.derby.client.am.MaterialStatement netStatement,
+ Cursor cursor,int sqlcsrhld,
+ int qryattscr,int qryattsns,int qryattset,long qryinsid,
+ int actualResultSetType,int actualResultSetConcurrency,
+ int actualResultSetHoldability) throws SqlException {
+ return new NetResultSet40((NetAgent)netAgent,(NetStatement)netStatement,
+ cursor,sqlcsrhld,qryattscr,qryattsns,qryattset,qryinsid,
+ actualResultSetType,actualResultSetConcurrency,
+ actualResultSetHoldability);
+ }
+ /**
+ * returns an instance of org.apache.derby.client.net.NetDatabaseMetaData
+ */
+ public org.apache.derby.client.am.DatabaseMetaData newNetDatabaseMetaData(Agent netAgent,
+ org.apache.derby.client.am.Connection netConnection) {
+ return new NetDatabaseMetaData40((NetAgent)netAgent,
+ (NetConnection)netConnection);
+ }
+}
Propchange: db/derby/code/trunk/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl40.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetCallableStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetCallableStatement.java?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetCallableStatement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetCallableStatement.java Thu Feb 23 10:22:35 2006
@@ -24,6 +24,8 @@
import org.apache.derby.client.am.MaterialPreparedStatement;
import org.apache.derby.client.am.Section;
import org.apache.derby.client.am.SqlException;
+import org.apache.derby.jdbc.ClientDriver;
+import org.apache.derby.client.am.ClientJDBCObjectFactory;
public class NetCallableStatement extends NetPreparedStatement
implements MaterialPreparedStatement {
@@ -70,7 +72,8 @@
int type,
int concurrency,
int holdability) throws SqlException {
- this(new CallableStatement(netAgent, netConnection, sql, type, concurrency, holdability),
+ this(ClientDriver.getFactory().newCallableStatement(netAgent,
+ netConnection, sql, type, concurrency, holdability),
netAgent,
netConnection);
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java Thu Feb 23 10:22:35 2006
@@ -30,6 +30,9 @@
import org.apache.derby.client.am.Statement;
import org.apache.derby.client.am.Utils;
import org.apache.derby.jdbc.ClientDataSource;
+import org.apache.derby.jdbc.ClientDriver;
+import org.apache.derby.client.am.ClientJDBCObjectFactory;
+
public class NetConnection extends org.apache.derby.client.am.Connection {
@@ -975,7 +978,7 @@
protected DatabaseMetaData newDatabaseMetaData_() {
- return new NetDatabaseMetaData(netAgent_, this);
+ return ClientDriver.getFactory().newNetDatabaseMetaData(netAgent_, this);
}
//-------------------private helper methods--------------------------------
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection40.java?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection40.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection40.java Thu Feb 23 10:22:35 2006
@@ -30,6 +30,10 @@
import java.sql.SQLException;
import java.sql.SQLXML;
import java.util.Properties;
+import org.apache.derby.client.am.SqlException;
+import org.apache.derby.impl.jdbc.Util;
+import org.apache.derby.jdbc.InternalDriver;
+
public class NetConnection40 extends org.apache.derby.client.net.NetConnection {
@@ -77,13 +81,32 @@
+ /**
+ * Constructs an object that implements the Clob interface. The object
+ * returned initially contains no data.
+ * @return An object that implements the Clob interface
+ * @throws SQLException if an object that implements the
+ * Clob interface can not be constructed.
+ *
+ */
public Clob createClob() throws SQLException {
- throw SQLExceptionFactory.notImplemented ("createClob ()");
+ org.apache.derby.client.am.Clob clob = new org.apache.derby.client.am.Clob(this.agent_,"");
+ return clob;
}
+ /**
+ * Constructs an object that implements the Clob interface. The object
+ * returned initially contains no data.
+ * @return An object that implements the Clob interface
+ * @throws SQLException if an object that implements the
+ * Clob interface can not be constructed.
+ *
+ */
+
public Blob createBlob() throws SQLException {
- throw SQLExceptionFactory.notImplemented ("createBlob ()");
+ org.apache.derby.client.am.Blob blob = new org.apache.derby.client.am.Blob(new byte[0],this.agent_, 0);
+ return blob;
}
public NClob createNClob() throws SQLException {
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetPreparedStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetPreparedStatement.java?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetPreparedStatement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetPreparedStatement.java Thu Feb 23 10:22:35 2006
@@ -23,6 +23,8 @@
import org.apache.derby.client.am.PreparedStatement;
import org.apache.derby.client.am.Section;
import org.apache.derby.client.am.SqlException;
+import org.apache.derby.jdbc.ClientDriver;
+import org.apache.derby.client.am.ClientJDBCObjectFactory;
public class NetPreparedStatement extends NetStatement
@@ -56,7 +58,9 @@
// Called by abstract Connection.prepareStatment().newPreparedStatement() for jdbc 2 prepared statements
// with scroll attributes.
NetPreparedStatement(NetAgent netAgent, NetConnection netConnection, String sql, int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames) throws SqlException {
- this(new PreparedStatement(netAgent, netConnection, sql, type, concurrency, holdability, autoGeneratedKeys, columnNames),
+ this(ClientDriver.getFactory().newPreparedStatement(netAgent,
+ netConnection, sql, type, concurrency, holdability,
+ autoGeneratedKeys, columnNames),
netAgent,
netConnection);
}
@@ -71,7 +75,8 @@
NetConnection netConnection,
String sql,
Section section) throws SqlException {
- this(new PreparedStatement(netAgent, netConnection, sql, section),
+ this(ClientDriver.getFactory().newPreparedStatement(netAgent,
+ netConnection, sql, section),
netAgent,
netConnection);
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet40.java?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet40.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet40.java Thu Feb 23 10:22:35 2006
@@ -32,7 +32,7 @@
public class NetResultSet40 extends NetResultSet{
- public NetResultSet40(NetAgent netAgent,
+ NetResultSet40(NetAgent netAgent,
NetStatement netStatement,
Cursor cursor,
//int qryprctyp, //protocolType, CodePoint.FIXROWPRC | CodePoint.LMTBLKPRC
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementReply.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementReply.java?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementReply.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementReply.java Thu Feb 23 10:22:35 2006
@@ -26,13 +26,15 @@
import org.apache.derby.client.am.ResultSetCallbackInterface;
import org.apache.derby.client.am.Section;
import org.apache.derby.client.am.SqlState;
+import org.apache.derby.client.am.SqlException;
import org.apache.derby.client.am.Statement;
import org.apache.derby.client.am.StatementCallbackInterface;
import org.apache.derby.client.am.Types;
import org.apache.derby.client.am.Utils;
+import org.apache.derby.jdbc.ClientDriver;
+import org.apache.derby.client.am.ClientJDBCObjectFactory;
import org.apache.derby.shared.common.reference.JDBC30Translation;
-
public class NetStatementReply extends NetPackageReply implements StatementReplyInterface {
NetStatementReply(NetAgent netAgent, int bufferSize) {
super(netAgent, bufferSize);
@@ -839,31 +841,42 @@
if (statement.cachedCursor_ != null) {
statement.cachedCursor_.resetDataBuffer();
((NetCursor) statement.cachedCursor_).extdtaData_.clear();
- rs = new NetResultSet(netAgent_,
- (NetStatement) statement.materialStatement_,
- statement.cachedCursor_,
- //qryprctyp, //protocolType, CodePoint.FIXROWPRC | CodePoint.LMTBLKPRC
- sqlcsrhld, //holdOption, 0xF0 for false (default) | 0xF1 for true.
- qryattscr, //scrollOption, 0xF0 for false (default) | 0xF1 for true.
- qryattsns, //sensitivity, CodePoint.QRYUNK | CodePoint.QRYINS
- qryattset,
- qryinsid, //instanceIdentifier, 0 (if not returned, check default) or number
- calculateResultSetType(qryattscr, qryattsns, statement.resultSetType_),
- calculateResultSetConcurrency(qryattupd, statement.resultSetConcurrency_),
- calculateResultSetHoldability(sqlcsrhld));
+ try {
+ rs = (NetResultSet)ClientDriver.getFactory().newNetResultSet
+ (netAgent_,
+ (NetStatement) statement.materialStatement_,
+ statement.cachedCursor_,
+ //qryprctyp, //protocolType, CodePoint.FIXROWPRC | CodePoint.LMTBLKPRC
+ sqlcsrhld, //holdOption, 0xF0 for false (default) | 0xF1 for true.
+ qryattscr, //scrollOption, 0xF0 for false (default) | 0xF1 for true.
+ qryattsns, //sensitivity, CodePoint.QRYUNK | CodePoint.QRYINS
+ qryattset,
+ qryinsid, //instanceIdentifier, 0 (if not returned, check default) or number
+ calculateResultSetType(qryattscr, qryattsns, statement.resultSetType_),
+ calculateResultSetConcurrency(qryattupd, statement.resultSetConcurrency_),
+ calculateResultSetHoldability(sqlcsrhld));
+ } catch(SqlException sqle) {
+ throw new DisconnectException(netAgent_,sqle);
+ }
} else {
- rs = new NetResultSet(netAgent_,
- (NetStatement) statement.materialStatement_,
- new NetCursor(netAgent_, qryprctyp),
- //qryprctyp, //protocolType, CodePoint.FIXROWPRC | CodePoint.LMTBLKPRC
- sqlcsrhld, //holdOption, 0xF0 for false (default) | 0xF1 for true.
- qryattscr, //scrollOption, 0xF0 for false (default) | 0xF1 for true.
- qryattsns, //sensitivity, CodePoint.QRYUNK | CodePoint.QRYINS
- qryattset,
- qryinsid, //instanceIdentifier, 0 (if not returned, check default) or number
- calculateResultSetType(qryattscr, qryattsns, statement.resultSetType_),
- calculateResultSetConcurrency(qryattupd, statement.resultSetConcurrency_),
- calculateResultSetHoldability(sqlcsrhld));
+ try {
+ rs = (NetResultSet)ClientDriver.getFactory().newNetResultSet
+ (netAgent_,
+ (NetStatement) statement.materialStatement_,
+ new NetCursor(netAgent_, qryprctyp),
+ //qryprctyp, //protocolType, CodePoint.FIXROWPRC | CodePoint.LMTBLKPRC
+ sqlcsrhld, //holdOption, 0xF0 for false (default) | 0xF1 for true.
+ qryattscr, //scrollOption, 0xF0 for false (default) | 0xF1 for true.
+ qryattsns, //sensitivity, CodePoint.QRYUNK | CodePoint.QRYINS
+ qryattset,
+ qryinsid, //instanceIdentifier, 0 (if not returned, check default) or number
+ calculateResultSetType(qryattscr, qryattsns, statement.resultSetType_),
+ calculateResultSetConcurrency(qryattupd, statement.resultSetConcurrency_),
+ calculateResultSetHoldability(sqlcsrhld));
+ } catch(SqlException sqle) {
+ throw new DisconnectException(netAgent_,sqle);
+ }
+
}
// QRYCLSIMP only applies to OPNQRY, not EXCSQLSTT
Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientConnectionPoolDataSource.java Thu Feb 23 10:22:35 2006
@@ -85,6 +85,7 @@
// method that establishes the initial physical connection
// using DS properties instead of CPDS properties.
private PooledConnection getPooledConnectionX(LogWriter dncLogWriter, ClientDataSource ds, String user, String password) throws SQLException {
- return new ClientPooledConnection(ds, dncLogWriter, user, password);
+ return ClientDriver.getFactory().newClientPooledConnection(ds,
+ dncLogWriter, user, password);
}
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java Thu Feb 23 10:22:35 2006
@@ -147,21 +147,24 @@
* @throws java.sql.SQLException if a database-access error occurs.
*/
public Connection getConnection(String user, String password) throws SQLException {
+ // Jdbc 2 connections will write driver trace info on a
+ // datasource-wide basis using the jdbc 2 data source log writer.
+ // This log writer may be narrowed to the connection-level
+ // This log writer will be passed to the agent constructor.
+
try
{
- // Jdbc 2 connections will write driver trace info on a
- // datasource-wide basis using the jdbc 2 data source log writer.
- // This log writer may be narrowed to the connection-level
- // This log writer will be passed to the agent constructor.
-
LogWriter dncLogWriter = super.computeDncLogWriterForNewConnection("_sds");
updateDataSourceValues(tokenizeAttributes(getConnectionAttributes(), null));
- return new NetConnection((NetLogWriter) dncLogWriter, user, password, this, -1, false);
+ return ClientDriver.getFactory().newNetConnection
+ ((NetLogWriter) dncLogWriter, user,
+ password, this, -1, false);
}
- catch ( SqlException se )
+ catch(SqlException se)
{
throw se.getSQLException();
}
+
}
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java Thu Feb 23 10:22:35 2006
@@ -23,12 +23,13 @@
import java.util.Enumeration;
import java.util.Properties;
import java.sql.SQLException;
-
import org.apache.derby.client.am.Configuration;
import org.apache.derby.client.am.ResourceUtilities;
import org.apache.derby.client.am.SqlException;
import org.apache.derby.client.am.Utils;
import org.apache.derby.client.am.Version;
+import org.apache.derby.client.am.ClientJDBCObjectFactory;
+import org.apache.derby.client.net.ClientJDBCObjectFactoryImpl;
import org.apache.derby.client.resources.ResourceKeys;
@@ -36,6 +37,8 @@
private transient int traceFileSuffixIndex_ = 0;
private final static int DERBY_REMOTE_PROTOCOL = 1;
+
+ private static ClientJDBCObjectFactory factoryObject = null;
static private SQLException exceptionsOnLoadDriver__ = null;
// Keep track of the registere driver so that we can deregister it if we're a stored proc.
@@ -66,8 +69,8 @@
public java.sql.Connection connect(String url,
java.util.Properties properties) throws java.sql.SQLException {
- try
- {
+ org.apache.derby.client.net.NetConnection conn;
+ try {
if (exceptionsOnLoadDriver__ != null) {
throw exceptionsOnLoadDriver__;
}
@@ -125,24 +128,24 @@
traceLevel,
"_driver",
traceFileSuffixIndex_++);
-
- org.apache.derby.client.net.NetConnection conn =
- new org.apache.derby.client.net.NetConnection((org.apache.derby.client.net.NetLogWriter) dncLogWriter,
- java.sql.DriverManager.getLoginTimeout(),
- server,
- port,
- database,
- augmentedProperties);
-
- if(conn.isConnectionNull())
- return null;
-
- return conn;
- }
- catch ( SqlException se )
- {
+
+
+ conn = (org.apache.derby.client.net.NetConnection)getFactory().
+ newNetConnection((org.apache.derby.client.net.NetLogWriter)
+ dncLogWriter,
+ java.sql.DriverManager.getLoginTimeout(),
+ server,
+ port,
+ database,
+ augmentedProperties);
+ } catch(SqlException se) {
throw se.getSQLException();
}
+
+ if(conn.isConnectionNull())
+ return null;
+
+ return conn;
}
/**
@@ -334,8 +337,61 @@
}
return ClientDataSource.tokenizeAttributes(attributeString, properties);
}
-
-
+
+ /**
+ *This method returns an Implementation
+ *of ClientJDBCObjectFactory depending on
+ *VM under use
+ *Currently it returns either
+ *ClientJDBCObjectFactoryImpl
+ *(or)
+ *ClientJDBCObjectFactoryImpl40
+ */
+
+ public static ClientJDBCObjectFactory getFactory() {
+ if(factoryObject!=null)
+ return factoryObject;
+ if(Configuration.supportsJDBC40()) {
+ factoryObject = createJDBC40FactoryImpl();
+ } else {
+ factoryObject = createDefaultFactoryImpl();
+ }
+ return factoryObject;
+ }
+
+ /**
+ *Returns an instance of the ClientJDBCObjectFactoryImpl class
+ */
+ private static ClientJDBCObjectFactory createDefaultFactoryImpl() {
+ return new ClientJDBCObjectFactoryImpl();
+ }
+
+ /**
+ *Returns an instance of the ClientJDBCObjectFactoryImpl40 class
+ *If a ClassNotFoundException occurs then it returns an
+ *instance of ClientJDBCObjectFactoryImpl
+ *
+ *If a future version of JDBC comes then
+ *a similar method would be added say createJDBCXXFactoryImpl
+ *in which if the class is not found then it would
+ *return the lower version thus having a sort of cascading effect
+ *until it gets a valid instance
+ */
+
+ private static ClientJDBCObjectFactory createJDBC40FactoryImpl() {
+ final String factoryName =
+ "org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40";
+ try {
+ return (ClientJDBCObjectFactory)
+ Class.forName(factoryName).newInstance();
+ } catch (ClassNotFoundException cnfe) {
+ return createDefaultFactoryImpl();
+ } catch (InstantiationException ie) {
+ return createDefaultFactoryImpl();
+ } catch (IllegalAccessException iae) {
+ return createDefaultFactoryImpl();
+ }
+ }
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement40.java?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement40.java Thu Feb 23 10:22:35 2006
@@ -26,6 +26,9 @@
import java.sql.NClob;
import java.sql.SQLException;
import java.sql.SQLXML;
+import java.sql.Types;
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.error.StandardException;
public class EmbedPreparedStatement40 extends EmbedPreparedStatement30{
@@ -52,15 +55,58 @@
throw Util.notImplemented();
}
+
+ /**
+ * Sets the designated parameter to a Reader object.
+ *
+ * @param parameterIndex index of the first parameter is 1, the second is 2, ...
+ * @param reader An object that contains the data to set the parameter value to.
+ * @param length the number of characters in the parameter data.
+ * @throws SQLException if parameterIndex does not correspond to a parameter
+ * marker in the SQL statement, or if the length specified is less than zero.
+ *
+ */
+
+
public void setClob(int parameterIndex, Reader reader, long length)
throws SQLException{
- throw Util.notImplemented();
+ int colType;
+ synchronized(getConnectionSynchronization()) {
+ colType = getParameterJDBCType(parameterIndex);
+ if(colType != Types.CLOB)
+ throw dataTypeConversion(parameterIndex, "java.sql.Clob");
+
+ setCharacterStreamInternal(parameterIndex,reader,length);
+ }
}
+
+ /**
+ * Sets the designated parameter to a InputStream object.
+ *
+ * @param parameterIndex index of the first parameter is 1,
+ * the second is 2, ...
+ * @param inputStream An object that contains the data to set the parameter
+ * value to.
+ * @param length the number of bytes in the parameter data.
+ * @throws SQLException if parameterIndex does not correspond
+ * to a parameter marker in the SQL statement, if the length specified
+ * is less than zero or if the number of bytes in the inputstream does not match
+ * the specfied length.
+ */
+
public void setBlob(int parameterIndex, InputStream inputStream, long length)
throws SQLException{
- throw Util.notImplemented();
+ int colType;
+ synchronized (getConnectionSynchronization()) {
+ colType = getParameterJDBCType(parameterIndex);
+ if (colType != Types.BLOB)
+ throw dataTypeConversion(parameterIndex, "java.sql.Blob");
+
+ setBinaryStreamInternal(parameterIndex,inputStream,length);
+ }
}
+
public void setNClob(int parameterIndex, Reader reader, long length)
throws SQLException{
throw Util.notImplemented();
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc4.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc4.properties?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc4.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc4.properties Thu Feb 23 10:22:35 2006
@@ -1,3 +1,4 @@
+framework=DerbyNetClient
runwithibm13=false
runwithibm14=false
runwithj9=false
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestCallableStatementMethods.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestCallableStatementMethods.java?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestCallableStatementMethods.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestCallableStatementMethods.java Thu Feb 23 10:22:35 2006
@@ -29,6 +29,10 @@
import java.sql.SQLXML;
import org.apache.derby.shared.common.reference.SQLState;
+/**
+ * This class is used to test the implementations of the JDBC 4.0 methods
+ * in the CallableStatement interface
+ */
public class TestCallableStatementMethods{
Connection conn=null;
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnection.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnection.java?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnection.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnection.java Thu Feb 23 10:22:35 2006
@@ -23,31 +23,50 @@
import java.sql.Connection;
import java.sql.DriverManager;
+ /**
+ * This class is used to create a connection. This class is then used by the
+ * other classes in the jdbc4 suite to create connection to a database
+ */
public class TestConnection {
TestConnection() {
}
+
+ /**
+ * This method creates a connection using the Embedded JDBC driver
+ */
Connection createEmbeddedConnection() {
Connection conn=null;
try {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
- conn = DriverManager.getConnection("jdbc:derby:mydb;create=true");
+ conn = DriverManager.getConnection("jdbc:derby:jdbc4_embedded_test_database;create=true");
} catch(Exception e) {
System.out.println("Failed in creating a Connection: "+e);
e.printStackTrace();
}
return conn;
}
+
+ /**
+ * This method creates a connection using the derby Client Driver
+ */
+
Connection createClientConnection() {
Connection conn=null;
try {
Class.forName("org.apache.derby.jdbc.ClientDriver");
- conn = DriverManager.getConnection("jdbc:derby:mydb;create=true");
+ conn = DriverManager.getConnection("jdbc:derby://localhost:1527/jdbc4_client_test_database" +
+ ";create=true");
} catch(Exception e) {
System.out.println("Failed in creating a Connection: "+e);
e.printStackTrace();
}
return conn;
}
+
+ /**
+ * closes the connection whose handle is given to the method
+ */
+
void closeConnection(Connection conn) {
try {
conn.close();
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java Thu Feb 23 10:22:35 2006
@@ -20,15 +20,28 @@
package org.apache.derbyTesting.functionTests.tests.jdbc4;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Connection;
+import java.sql.PreparedStatement;
import java.sql.NClob;
import java.sql.SQLException;
import java.sql.SQLXML;
+import java.sql.Statement;
import java.util.Properties;
import org.apache.derby.shared.common.reference.SQLState;
+/**
+ * This class is used to test the implementations of the JDBC 4.0 methods
+ * in the Connection interface
+ */
+
public class TestConnectionMethods {
Connection conn = null;
@@ -63,6 +76,75 @@
System.out.println("Unexpected exception caught in function"+e);
}
}
+ /**
+ * Test the createClob method implementation in the Connection interface
+ * in the Network Client
+ */
+ void t_createClob_Client() {
+ int c;
+ Clob clob;
+ try {
+ Statement s = conn.createStatement();
+ s.execute("create table clobtable2(n int,clobcol CLOB)");
+ PreparedStatement ps = conn.prepareStatement("insert into clobtable2" +
+ " values(?,?)");
+ ps.setInt(1,1000);
+ clob = conn.createClob();
+ File file = new File("extin/short.txt");
+ FileInputStream is = new FileInputStream(file);
+ OutputStream os = clob.setAsciiStream(1);
+ c = is.read();
+ while(c>0) {
+ os.write(c);
+ c = is.read();
+ }
+ ps.setClob(2, clob);
+ ps.executeUpdate();
+ } catch(SQLException e) {
+ e.printStackTrace();
+ } catch(FileNotFoundException fnfe){
+ fnfe.printStackTrace();
+ } catch(IOException ioe) {
+ ioe.printStackTrace();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ /**
+ * Test the createBlob method implementation in the Connection interface for
+ * in the Network Client
+ */
+ void t_createBlob_Client() {
+ int c;
+ Blob blob;
+ try {
+ Statement s = conn.createStatement();
+ s.execute("create table blobtable2(n int,blobcol BLOB)");
+ PreparedStatement ps = conn.prepareStatement("insert into blobtable2" +
+ " values(?,?)");
+ ps.setInt(1,1000);
+ blob = conn.createBlob();
+ File file = new File("extin/short.txt");
+ FileInputStream is = new FileInputStream(file);
+ OutputStream os = blob.setBinaryStream(1);
+ c = is.read();
+ while(c>0) {
+ os.write(c);
+ c = is.read();
+ }
+ ps.setBlob(2, blob);
+ ps.executeUpdate();
+ } catch(SQLException e) {
+ e.printStackTrace();
+ } catch(FileNotFoundException fnfe){
+ fnfe.printStackTrace();
+ } catch(IOException ioe) {
+ ioe.printStackTrace();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
void t_createNClob() {
NClob nclob;
try {
@@ -161,7 +243,19 @@
}
}
- public void startTestConnectionMethods() {
+ public void startTestConnectionMethods_Client() {
+ t_createClob_Client();
+ t_createBlob_Client();
+ t_createNClob();
+ t_createSQLXML();
+ t_isValid();
+ t_setClientInfo1();
+ t_setClientInfo2();
+ t_getClientInfo1();
+ t_getClientInfo2();
+ }
+
+ public void startTestConnectionMethods_Embedded() {
t_createClob();
t_createBlob();
t_createNClob();
@@ -177,11 +271,17 @@
Connection connEmbedded = tc.createEmbeddedConnection();
TestConnectionMethods tcm = new TestConnectionMethods(connEmbedded);
- tcm.startTestConnectionMethods();
+ tcm.startTestConnectionMethods_Embedded();
Connection connNetwork = tc.createClientConnection();
TestConnectionMethods tcm1 = new TestConnectionMethods(connNetwork);
- tcm1.startTestConnectionMethods();
+ tcm1.startTestConnectionMethods_Client();
+ try {
+ connEmbedded.close();
+ connNetwork.close();
+ } catch(SQLException sqle){
+ sqle.printStackTrace();
+ }
}
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods_app.properties?rev=380187&r1=380186&r2=380187&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods_app.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods_app.properties Thu Feb 23 10:22:35 2006
@@ -4,3 +4,5 @@
runwithjdk12=false
runwithjdk13=false
runwithjdk14=false
+supportfiles=tests/jdbc4/short.txt,tests/jdbc4/littleclob.txt,tests/jdbc4/aclob.txt
+useextdirs=true
\ No newline at end of file