You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2013/06/17 12:12:42 UTC
svn commit: r1493707 - in /db/derby/code/trunk/java:
drda/org/apache/derby/impl/drda/ engine/org/apache/derby/catalog/
engine/org/apache/derby/diag/ engine/org/apache/derby/iapi/jdbc/
engine/org/apache/derby/impl/jdbc/ engine/org/apache/derby/jdbc/ tes...
Author: kahatlen
Date: Mon Jun 17 10:12:42 2013
New Revision: 1493707
URL: http://svn.apache.org/r1493707
Log:
DERBY-1984: Re-factor JDBC classes to remove support for JDBC 2
Move methods supporting JDBC versions up to 4.1 into the base class
for the implementations of the following JDBC interfaces in the
embedded driver:
java.sql.ResultSet
java.sql.DatabaseMetaData
java.sql.ParameterMetaData
java.sql.ResultSetMetaData
Removed:
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineParameterMetaData.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData40.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterMetaData30.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet20.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData40.java
Modified:
db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java
db/derby/code/trunk/java/engine/org/apache/derby/catalog/GetProcedureColumns.java
db/derby/code/trunk/java/engine/org/apache/derby/diag/ContainedRoles.java
db/derby/code/trunk/java/engine/org/apache/derby/diag/ErrorLogReader.java
db/derby/code/trunk/java/engine/org/apache/derby/diag/ErrorMessages.java
db/derby/code/trunk/java/engine/org/apache/derby/diag/LockTable.java
db/derby/code/trunk/java/engine/org/apache/derby/diag/SpaceTable.java
db/derby/code/trunk/java/engine/org/apache/derby/diag/StatementCache.java
db/derby/code/trunk/java/engine/org/apache/derby/diag/StatementDuration.java
db/derby/code/trunk/java/engine/org/apache/derby/diag/TransactionTable.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineResultSet.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterSetMetaData.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet42.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java
db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41.java
Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java?rev=1493707&r1=1493706&r2=1493707&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java Mon Jun 17 10:12:42 2013
@@ -55,7 +55,6 @@ import org.apache.derby.iapi.jdbc.Authen
import org.apache.derby.iapi.jdbc.EngineLOB;
import org.apache.derby.iapi.jdbc.EngineStatement;
import org.apache.derby.iapi.jdbc.EnginePreparedStatement;
-import org.apache.derby.iapi.jdbc.EngineResultSet;
import org.apache.derby.iapi.reference.Attribute;
import org.apache.derby.iapi.reference.DRDAConstants;
import org.apache.derby.iapi.reference.Property;
@@ -4546,7 +4545,7 @@ class DRDAConnThread extends Thread {
writer.createDssObject();
writer.startDdm(CodePoint.SQLCINRD);
if (sqlamLevel >= MGRLVL_7) {
- writeSQLDHROW(((EngineResultSet) rs).getHoldability());
+ writeSQLDHROW(rs.getHoldability());
}
ResultSetMetaData rsmeta = rs.getMetaData();
Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java?rev=1493707&r1=1493706&r2=1493707&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java Mon Jun 17 10:12:42 2013
@@ -37,7 +37,6 @@ import java.util.ArrayList;
import java.util.Hashtable;
import org.apache.derby.iapi.jdbc.EngineStatement;
import org.apache.derby.iapi.jdbc.EnginePreparedStatement;
-import org.apache.derby.iapi.jdbc.EngineResultSet;
import org.apache.derby.iapi.transaction.TransactionControl;
import org.apache.derby.iapi.util.StringUtil;
import org.apache.derby.impl.jdbc.Util;
@@ -734,7 +733,7 @@ class DRDAStatement
{
//For callable statement, get holdability of statement generating the result set
if(isCallable)
- addResultSet(rs, ((EngineResultSet) rs).getHoldability());
+ addResultSet(rs, rs.getHoldability());
else
addResultSet(rs,withHoldCursor);
hasResultSet = true;
Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/GetProcedureColumns.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/catalog/GetProcedureColumns.java?rev=1493707&r1=1493706&r2=1493707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/catalog/GetProcedureColumns.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/catalog/GetProcedureColumns.java Mon Jun 17 10:12:42 2013
@@ -30,7 +30,6 @@ import org.apache.derby.iapi.types.DataT
import org.apache.derby.iapi.types.DataTypeUtilities;
import org.apache.derby.iapi.sql.ResultColumnDescriptor;
import org.apache.derby.impl.jdbc.EmbedResultSetMetaData;
-import org.apache.derby.impl.jdbc.EmbedResultSetMetaData40;
import org.apache.derby.catalog.types.RoutineAliasInfo;
/**
@@ -330,5 +329,7 @@ public class GetProcedureColumns extends
EmbedResultSetMetaData.getResultColumnDescriptor("METHOD_ID", Types.SMALLINT, false),
EmbedResultSetMetaData.getResultColumnDescriptor("PARAMETER_ID", Types.SMALLINT, false),
};
- private static final ResultSetMetaData metadata = new EmbedResultSetMetaData40(columnInfo);
+
+ private static final ResultSetMetaData metadata =
+ new EmbedResultSetMetaData(columnInfo);
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/diag/ContainedRoles.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/diag/ContainedRoles.java?rev=1493707&r1=1493706&r2=1493707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/diag/ContainedRoles.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/diag/ContainedRoles.java Mon Jun 17 10:12:42 2013
@@ -37,7 +37,6 @@ import org.apache.derby.iapi.util.IdUtil
import org.apache.derby.vti.VTITemplate;
import org.apache.derby.impl.jdbc.EmbedResultSetMetaData;
-import org.apache.derby.impl.jdbc.EmbedResultSetMetaData40;
/**
@@ -172,6 +171,6 @@ public class ContainedRoles extends VTIT
};
private static final ResultSetMetaData metadata =
- new EmbedResultSetMetaData40(columnInfo);
+ new EmbedResultSetMetaData(columnInfo);
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/diag/ErrorLogReader.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/diag/ErrorLogReader.java?rev=1493707&r1=1493706&r2=1493707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/diag/ErrorLogReader.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/diag/ErrorLogReader.java Mon Jun 17 10:12:42 2013
@@ -29,9 +29,6 @@ import java.io.FileInputStream;
import java.security.PrivilegedAction;
import java.security.AccessController;
-import java.util.Hashtable;
-import java.util.Enumeration;
-import java.util.Properties;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Types;
@@ -43,7 +40,6 @@ import org.apache.derby.iapi.util.String
import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.sql.ResultColumnDescriptor;
import org.apache.derby.impl.jdbc.EmbedResultSetMetaData;
-import org.apache.derby.impl.jdbc.EmbedResultSetMetaData40;
/**
@@ -348,7 +344,9 @@ public class ErrorLogReader extends VTIT
EmbedResultSetMetaData.getResultColumnDescriptor("DRDAID", Types.VARCHAR, true, 50),
EmbedResultSetMetaData.getResultColumnDescriptor("LOGTEXT",Types.VARCHAR, false, Limits.DB2_VARCHAR_MAXWIDTH)
};
- private static final ResultSetMetaData metadata = new EmbedResultSetMetaData40(columnInfo);
+
+ private static final ResultSetMetaData metadata =
+ new EmbedResultSetMetaData(columnInfo);
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/diag/ErrorMessages.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/diag/ErrorMessages.java?rev=1493707&r1=1493706&r2=1493707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/diag/ErrorMessages.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/diag/ErrorMessages.java Mon Jun 17 10:12:42 2013
@@ -21,8 +21,6 @@
package org.apache.derby.diag;
-import java.util.Hashtable;
-import java.util.Enumeration;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Types;
@@ -30,9 +28,6 @@ import java.util.Properties;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
-import org.apache.derby.vti.VTICosting;
-import org.apache.derby.vti.VTIEnvironment;
-import java.lang.Math;
import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.error.ExceptionSeverity;
import org.apache.derby.iapi.services.i18n.MessageService;
@@ -44,7 +39,6 @@ import org.apache.derby.vti.VTICosting;
import org.apache.derby.vti.VTIEnvironment;
import org.apache.derby.impl.jdbc.EmbedResultSetMetaData;
-import org.apache.derby.impl.jdbc.EmbedResultSetMetaData40;
import org.apache.derby.iapi.sql.ResultColumnDescriptor;
@@ -233,7 +227,8 @@ public final class ErrorMessages extends
EmbedResultSetMetaData.getResultColumnDescriptor("MESSAGE", Types.VARCHAR, true, Limits.DB2_VARCHAR_MAXWIDTH),
EmbedResultSetMetaData.getResultColumnDescriptor("SEVERITY", Types.INTEGER, true),
};
-
- private static final ResultSetMetaData metadata = new EmbedResultSetMetaData40(columnInfo);
+
+ private static final ResultSetMetaData metadata =
+ new EmbedResultSetMetaData(columnInfo);
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/diag/LockTable.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/diag/LockTable.java?rev=1493707&r1=1493706&r2=1493707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/diag/LockTable.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/diag/LockTable.java Mon Jun 17 10:12:42 2013
@@ -38,7 +38,6 @@ import org.apache.derby.iapi.error.Publi
import org.apache.derby.iapi.sql.ResultColumnDescriptor;
import org.apache.derby.impl.jdbc.EmbedResultSetMetaData;
-import org.apache.derby.impl.jdbc.EmbedResultSetMetaData40;
import java.util.Hashtable;
import java.util.Enumeration;
@@ -341,6 +340,7 @@ public class LockTable extends VTITempla
EmbedResultSetMetaData.getResultColumnDescriptor(VirtualLockTable.INDEXNAME, Types.VARCHAR, true, 128)
};
- private static final ResultSetMetaData metadata = new EmbedResultSetMetaData40(columnInfo);
+ private static final ResultSetMetaData metadata =
+ new EmbedResultSetMetaData(columnInfo);
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/diag/SpaceTable.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/diag/SpaceTable.java?rev=1493707&r1=1493706&r2=1493707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/diag/SpaceTable.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/diag/SpaceTable.java Mon Jun 17 10:12:42 2013
@@ -21,7 +21,6 @@
package org.apache.derby.diag;
-import org.apache.derby.iapi.services.monitor.Monitor;
import org.apache.derby.iapi.services.sanity.SanityManager;
import org.apache.derby.iapi.error.StandardException;
@@ -31,7 +30,6 @@ import org.apache.derby.iapi.sql.diction
import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
-import org.apache.derby.iapi.store.access.AccessFactory;
import org.apache.derby.iapi.store.access.TransactionController;
import org.apache.derby.iapi.store.access.ConglomerateController;
import org.apache.derby.iapi.store.access.SpaceInfo;
@@ -39,7 +37,6 @@ import org.apache.derby.iapi.error.Publi
import org.apache.derby.iapi.sql.ResultColumnDescriptor;
import org.apache.derby.impl.jdbc.EmbedResultSetMetaData;
-import org.apache.derby.impl.jdbc.EmbedResultSetMetaData40;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
@@ -378,7 +375,8 @@ public class SpaceTable extends VTITempl
EmbedResultSetMetaData.getResultColumnDescriptor("TABLEID", Types.CHAR, false, 36),
};
- private static final ResultSetMetaData metadata = new EmbedResultSetMetaData40(columnInfo);
+ private static final ResultSetMetaData metadata =
+ new EmbedResultSetMetaData(columnInfo);
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/diag/StatementCache.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/diag/StatementCache.java?rev=1493707&r1=1493706&r2=1493707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/diag/StatementCache.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/diag/StatementCache.java Mon Jun 17 10:12:42 2013
@@ -22,7 +22,6 @@
package org.apache.derby.diag;
import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import java.util.Collection;
@@ -37,7 +36,6 @@ import org.apache.derby.iapi.sql.ResultC
import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
import org.apache.derby.iapi.util.StringUtil;
import org.apache.derby.impl.jdbc.EmbedResultSetMetaData;
-import org.apache.derby.impl.jdbc.EmbedResultSetMetaData40;
import org.apache.derby.impl.sql.GenericPreparedStatement;
import org.apache.derby.impl.sql.GenericStatement;
import org.apache.derby.impl.sql.conn.CachedStatement;
@@ -176,7 +174,8 @@ public final class StatementCache extend
};
- private static final ResultSetMetaData metadata = new EmbedResultSetMetaData40(columnInfo);
+ private static final ResultSetMetaData metadata =
+ new EmbedResultSetMetaData(columnInfo);
public ResultSetMetaData getMetaData() {
Modified: db/derby/code/trunk/java/engine/org/apache/derby/diag/StatementDuration.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/diag/StatementDuration.java?rev=1493707&r1=1493706&r2=1493707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/diag/StatementDuration.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/diag/StatementDuration.java Mon Jun 17 10:12:42 2013
@@ -30,8 +30,6 @@ import java.security.PrivilegedAction;
import java.security.AccessController;
import java.text.SimpleDateFormat;
import java.util.Hashtable;
-import java.util.Enumeration;
-import java.util.Properties;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Timestamp;
@@ -41,7 +39,6 @@ import org.apache.derby.vti.VTITemplate;
import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.sql.ResultColumnDescriptor;
import org.apache.derby.impl.jdbc.EmbedResultSetMetaData;
-import org.apache.derby.impl.jdbc.EmbedResultSetMetaData40;
import org.apache.derby.iapi.reference.Limits;
import org.apache.derby.iapi.reference.Property;
import org.apache.derby.iapi.util.StringUtil;
@@ -399,6 +396,7 @@ public class StatementDuration extends V
EmbedResultSetMetaData.getResultColumnDescriptor("DURATION", Types.VARCHAR, false, 10),
};
- private static final ResultSetMetaData metadata = new EmbedResultSetMetaData40(columnInfo);
+ private static final ResultSetMetaData metadata =
+ new EmbedResultSetMetaData(columnInfo);
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/diag/TransactionTable.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/diag/TransactionTable.java?rev=1493707&r1=1493706&r2=1493707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/diag/TransactionTable.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/diag/TransactionTable.java Mon Jun 17 10:12:42 2013
@@ -32,7 +32,6 @@ import org.apache.derby.vti.VTIEnvironme
import org.apache.derby.iapi.sql.ResultColumnDescriptor;
import org.apache.derby.impl.jdbc.EmbedResultSetMetaData;
-import org.apache.derby.impl.jdbc.EmbedResultSetMetaData40;
import org.apache.derby.iapi.reference.Limits;
import org.apache.derby.iapi.util.StringUtil;
@@ -240,6 +239,7 @@ public class TransactionTable extends VT
EmbedResultSetMetaData.getResultColumnDescriptor("SQL_TEXT", Types.VARCHAR, true, Limits.DB2_VARCHAR_MAXWIDTH),
};
- private static final ResultSetMetaData metadata = new EmbedResultSetMetaData40(columnInfo);
+ private static final ResultSetMetaData metadata =
+ new EmbedResultSetMetaData(columnInfo);
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineResultSet.java?rev=1493707&r1=1493706&r2=1493707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineResultSet.java Mon Jun 17 10:12:42 2013
@@ -23,7 +23,6 @@ package org.apache.derby.iapi.jdbc;
import java.sql.ResultSet;
import java.sql.SQLException;
-import org.apache.derby.iapi.error.StandardException;
/**
* Additional methods the embedded engine exposes on its ResultSet object
* implementations. An internal api only, mainly for the network
@@ -57,12 +56,4 @@ public interface EngineResultSet extends
*/
public int getLength(int columnIndex) throws SQLException;
- /**
- * Fetch the holdability of this ResultSet which may be different
- * from the holdability of its Statement.
- * @return HOLD_CURSORS_OVER_COMMIT or CLOSE_CURSORS_AT_COMMIT
- * @throws SQLException Error.
- */
- public int getHoldability() throws SQLException;
-
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java?rev=1493707&r1=1493706&r2=1493707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java Mon Jun 17 10:12:42 2013
@@ -35,7 +35,6 @@ import org.apache.derby.iapi.sql.diction
import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.impl.sql.execute.GenericConstantActionFactory;
-import org.apache.derby.impl.sql.execute.GenericExecutionFactory;
import org.apache.derby.iapi.reference.SQLState;
import org.apache.derby.iapi.reference.Limits;
@@ -47,6 +46,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.ResultSet;
+import java.sql.RowIdLifetime;
import java.sql.Types;
import java.io.IOException;
@@ -86,7 +86,7 @@ import org.apache.derby.iapi.util.Interr
*
* @see <a href="http://java.sun.com/products/jdbc/download.html#corespec30">JDBC 3.0 Specification</a>
*/
-public abstract class EmbedDatabaseMetaData extends ConnectionChild
+public class EmbedDatabaseMetaData extends ConnectionChild
implements DatabaseMetaData, java.security.PrivilegedAction<Object> {
private static final int ILLEGAL_UDT_TYPE = 0;
@@ -3294,7 +3294,7 @@ public abstract class EmbedDatabaseMetaD
*/
public int getJDBCMajorVersion()
{
- return 3;
+ return 4;
}
/**
@@ -3306,7 +3306,7 @@ public abstract class EmbedDatabaseMetaD
*/
public int getJDBCMinorVersion()
{
- return 0;
+ return 1;
}
/**
@@ -3467,6 +3467,56 @@ public abstract class EmbedDatabaseMetaD
return s.executeQuery();
}
+ public RowIdLifetime getRowIdLifetime() throws SQLException {
+ return RowIdLifetime.ROWID_UNSUPPORTED;
+ }
+
+ public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
+ return true;
+ }
+
+ /**
+ * Returns whether or not all open {@code ResultSet}s on a {@code
+ * Connection} are closed if an error occurs when auto-commit in enabled.
+ *
+ * @return {@code true}, since the embedded driver will close the open
+ * {@code ResultSet}s
+ */
+ public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
+ return true;
+ }
+
+ // java.sql.Wrapper interface methods
+
+ /**
+ * Returns whether or not this instance implements the specified interface.
+ *
+ * @param iface the interface to check for
+ * @return true if this implements the interface
+ */
+ public final boolean isWrapperFor(Class<?> iface) {
+ return iface.isInstance(this);
+ }
+
+ /**
+ * Returns {@code this} if this class implements the interface.
+ *
+ * @param iface the interface
+ * @return an object that implements the interface
+ * @throws SQLException if no object is found that implements the
+ * interface
+ */
+ public final <T> T unwrap(Class<T> iface) throws SQLException {
+ // Derby does not implement non-standard methods on JDBC objects,
+ // hence return this if this class implements the interface
+ // or throw an SQLException.
+ try {
+ return iface.cast(this);
+ } catch (ClassCastException cce) {
+ throw newSQLException(SQLState.UNABLE_TO_UNWRAP, iface);
+ }
+ }
+
/////////////////////////////////////////////////////////////////////////
//
// JDBC 4.1 - New public methods
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterSetMetaData.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterSetMetaData.java?rev=1493707&r1=1493706&r2=1493707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterSetMetaData.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterSetMetaData.java Mon Jun 17 10:12:42 2013
@@ -25,25 +25,14 @@ import org.apache.derby.iapi.sql.Paramet
import org.apache.derby.iapi.types.DataTypeDescriptor;
import org.apache.derby.iapi.types.DataTypeUtilities;
import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.iapi.jdbc.EngineParameterMetaData;
import java.sql.ParameterMetaData;
import java.sql.SQLException;
/**
- * This class immitates to implement the ParameterMetaData interface from JDBC3.0
- * We want to provide the functionality to JDKs before JDBC3.0. We put it here
- * instead of in Local20 because we want to make it available for CallableStatement.
- * It provides the parameter meta data for callable & prepared statements.
- * The subclass in Local30 actually implements ParameterMetaData interface.
- *
- * For use of ParameterMetaData functionality in network server, please do not use
- * this class directly. Instead use the method available on EnginePreparedStatement
- * @see org.apache.derby.iapi.jdbc.EngineParameterMetaData
- * @see org.apache.derby.iapi.jdbc.EnginePreparedStatement
+ * This class implements the ParameterMetaData interface from JDBC 3.0.
*/
-public class EmbedParameterSetMetaData implements EngineParameterMetaData
- {
+public class EmbedParameterSetMetaData implements ParameterMetaData {
private final ParameterValueSet pvs;
private final DataTypeDescriptor[] types;
@@ -229,5 +218,39 @@ public class EmbedParameterSetMetaData i
new Integer(parameterIndex), new Integer(paramCount));
}
}
+
+ // java.sql.Wrapper interface methods
+
+ /**
+ * Returns false unless {@code iface} is implemented.
+ *
+ * @param iface a class defining an interface
+ * @return true if this implements the interface or directly or indirectly
+ * wraps an object that does
+ * @throws SQLException if an error occurs while determining whether this is
+ * a wrapper for an object with the given interface.
+ */
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ return iface.isInstance(this);
+ }
+
+ /**
+ * Returns {@code this} if this class implements the specified interface.
+ *
+ * @param iface a class defining an interface
+ * @return an object that implements the interface
+ * @throws SQLException if no object is found that implements the interface
+ */
+ public <T> T unwrap(Class<T> iface) throws SQLException {
+ // Derby does not implement non-standard methods on JDBC objects,
+ // hence return this if this class implements the interface, or
+ // throw an SQLException.
+ try {
+ return iface.cast(this);
+ } catch (ClassCastException cce) {
+ throw Util.generateCsSQLException(SQLState.UNABLE_TO_UNWRAP, iface);
+ }
+ }
+
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java?rev=1493707&r1=1493706&r2=1493707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java Mon Jun 17 10:12:42 2013
@@ -69,7 +69,6 @@ import java.sql.SQLXML;
import java.sql.Types;
import org.apache.derby.iapi.jdbc.BrokeredConnectionControl;
-import org.apache.derby.iapi.jdbc.EngineParameterMetaData;
import org.apache.derby.iapi.jdbc.EnginePreparedStatement;
import org.apache.derby.iapi.services.loader.GeneratedClass;
import org.apache.derby.iapi.sql.dictionary.DataDictionary;
@@ -959,7 +958,7 @@ public class EmbedPreparedStatement exte
// in that case the cast to int would not be appropriate.
if ( !lengthLess && length > Integer.MAX_VALUE ) {
throw newSQLException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE,
- getEmbedParameterSetMetaData().getParameterTypeName(
+ getParameterMetaData().getParameterTypeName(
parameterIndex));
}
@@ -1652,25 +1651,6 @@ public class EmbedPreparedStatement exte
}
}
-
- /**
- * Immitate the function in JDBC 3.0
- *
- * Retrieves the number, types and properties of this PreparedStatement
- * object's parameters.
- *
- * @return a EngineParameterMetaData object that contains information about the
- * number, types and properties of this PreparedStatement object's parameters.
- * @exception SQLException if a database access error occurs
- */
- private EngineParameterMetaData getEmbedParameterSetMetaData()
- throws SQLException
- {
- checkExecStatus();
- return new EmbedParameterSetMetaData(
- getParms(), preparedStatement.getParameterTypes());
-
- }
/**
* JDBC 3.0
*
@@ -1701,7 +1681,7 @@ public class EmbedPreparedStatement exte
public final ParameterMetaData getParameterMetaData()
throws SQLException {
checkStatus();
- return new EmbedParameterMetaData30(
+ return new EmbedParameterSetMetaData(
getParms(), preparedStatement.getParameterTypes());
}
@@ -1742,9 +1722,9 @@ public class EmbedPreparedStatement exte
final SQLException dataTypeConversion(int column, String sourceType)
throws SQLException {
- SQLException se = newSQLException(SQLState.LANG_DATA_TYPE_GET_MISMATCH, getEmbedParameterSetMetaData().getParameterTypeName(column),
+ return newSQLException(SQLState.LANG_DATA_TYPE_GET_MISMATCH,
+ getParameterMetaData().getParameterTypeName(column),
sourceType);
- return se;
}
/**
* This method is used to initialize the BrokeredConnectionControl
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java?rev=1493707&r1=1493706&r2=1493707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java Mon Jun 17 10:12:42 2013
@@ -49,7 +49,6 @@ import org.apache.derby.iapi.types.Reade
import org.apache.derby.iapi.types.UserDataValue;
import org.apache.derby.iapi.types.VariableSizeDataValue;
import org.apache.derby.iapi.sql.ResultDescription;
-import org.apache.derby.iapi.services.io.StreamStorable;
import org.apache.derby.iapi.services.io.LimitInputStream;
import org.apache.derby.iapi.error.ExceptionSeverity;
@@ -72,27 +71,32 @@ import java.sql.Types;
import java.io.Reader;
import java.io.InputStream;
import java.io.IOException;
+import java.math.BigDecimal;
import java.net.URL;
+import java.sql.Array;
+import java.sql.NClob;
+import java.sql.Ref;
+import java.sql.RowId;
+import java.sql.SQLXML;
import java.util.Arrays;
import java.util.Calendar;
+import java.util.Map;
import org.apache.derby.iapi.jdbc.CharacterStreamDescriptor;
import org.apache.derby.iapi.services.io.CloseFilterInputStream;
import org.apache.derby.iapi.sql.dictionary.DataDictionary;
+import org.apache.derby.iapi.types.SQLDecimal;
import org.apache.derby.iapi.types.StringDataValue;
import org.apache.derby.iapi.util.IdUtil;
import org.apache.derby.iapi.util.InterruptStatus;
/**
- * A EmbedResultSet for results from the EmbedStatement family.
- <P><B>Supports</B>
- <UL>
- <LI> JSR 169
- </UL>
+ * A EmbedResultSet for results from the EmbedStatement family.
+ * Supports JDBC 4.1.
*/
-public abstract class EmbedResultSet extends ConnectionChild
+public class EmbedResultSet extends ConnectionChild
implements EngineResultSet, Comparable {
/** For use in debugging setLargeMaxRows() method added by JDBC 4.2 */
@@ -1421,6 +1425,71 @@ public abstract class EmbedResultSet ext
}
/**
+ * Get the value of a column in the current row as a java.lang.BigDecimal
+ * object.
+ *
+ * @param columnIndex the first column is 1, the second is 2, ...
+ * @param scale the number of digits to the right of the decimal
+ * @return the column value; if the value is SQL NULL, the result is null
+ * @exception SQLException thrown on failure.
+ */
+ @Deprecated
+ public final BigDecimal getBigDecimal(int columnIndex, int scale)
+ throws SQLException {
+
+ BigDecimal ret = getBigDecimal(columnIndex);
+ if (ret != null) {
+ return ret.setScale(scale, BigDecimal.ROUND_HALF_DOWN);
+ }
+ return null;
+ }
+
+ public final BigDecimal getBigDecimal(int columnIndex)
+ throws SQLException {
+ checkIfClosed("getBigDecimal");
+ try {
+
+ DataValueDescriptor dvd = getColumn(columnIndex);
+
+ if (wasNull = dvd.isNull()) {
+ return null;
+ }
+
+ return SQLDecimal.getBigDecimal(dvd);
+
+ } catch (StandardException t) {
+ throw noStateChangeException(t);
+ }
+ }
+
+ /**
+ * Get the value of a column in the current row as a java.lang.BigDecimal
+ * object.
+ *
+ * @param columnName is the SQL name of the column
+ * @param scale the number of digits to the right of the decimal
+ * @return the column value; if the value is SQL NULL, the result is null
+ * @exception SQLException thrown on failure.
+ */
+ @Deprecated
+ public final BigDecimal getBigDecimal(String columnName, int scale)
+ throws SQLException {
+ checkIfClosed("getBigDecimal");
+ return getBigDecimal(findColumnName(columnName), scale);
+ }
+
+ /**
+ * JDBC 2.0
+ *
+ * Get the value of a column in the current row as a java.math.BigDecimal
+ * object.
+ */
+ public final BigDecimal getBigDecimal(String columnName) throws SQLException {
+ checkIfClosed("getBigDecimal");
+ return getBigDecimal(findColumnName(columnName));
+ }
+
+ /**
* Get the value of a column in the current row as a Java byte array.
* The bytes represent the raw values returned by the driver.
*
@@ -1524,6 +1593,28 @@ public abstract class EmbedResultSet ext
}
/**
+ * JDBC 2.0
+ *
+ * Deprecated in JDBC 2.0, not supported by JCC.
+ *
+ * @exception SQLException thrown on failure.
+ */
+ @Deprecated
+ public final java.io.InputStream getUnicodeStream(int columnIndex) throws SQLException {
+ throw Util.notImplemented("getUnicodeStream");
+ }
+
+ /**
+ * Deprecated in JDBC 2.0, not supported by JCC.
+ *
+ * @exception SQLException thrown on failure.
+ */
+ @Deprecated
+ public final java.io.InputStream getUnicodeStream(String columnName) throws SQLException {
+ throw Util.notImplemented("getUnicodeStream");
+ }
+
+ /**
* JDBC 3.0
*
* Retrieves the value of the designated column in the current row of this
@@ -1761,6 +1852,48 @@ public abstract class EmbedResultSet ext
return (getObject(findColumnName(columnName)));
}
+ /**
+ * JDBC 2.0
+ *
+ * Returns the value of column {@code i} as a Java object. Use the param map
+ * to determine the class from which to construct data of SQL structured and
+ * distinct types.
+ *
+ * @param columnIndex the first column is 1, the second is 2, ...
+ * @param map the mapping from SQL type names to Java classes
+ * @return an object representing the SQL value
+ * @exception SQLException Feature not implemented for now.
+ */
+ public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException {
+ checkIfClosed("getObject");
+ if (map == null) {
+ throw Util.generateCsSQLException(SQLState.INVALID_API_PARAMETER, map, "map",
+ "java.sql.ResultSet.getObject");
+ }
+ if (!(map.isEmpty())) {
+ throw Util.notImplemented();
+ }
+ // Map is empty call the normal getObject method.
+ return getObject(columnIndex);
+ }
+
+ /**
+ * JDBC 2.0
+ *
+ * Returns the value of column {@code i} as a Java object. Use the param map
+ * to determine the class from which to construct data of SQL structured and
+ * distinct types.
+ *
+ * @param colName the column name
+ * @param map the mapping from SQL type names to Java classes
+ * @return an object representing the SQL value
+ * @exception SQLException Feature not implemented for now.
+ */
+ public Object getObject(String colName, Map<String, Class<?>> map)
+ throws SQLException {
+ checkIfClosed("getObject");
+ return getObject(findColumn(colName), map);
+ }
//----------------------------------------------------------------
@@ -1813,6 +1946,58 @@ public abstract class EmbedResultSet ext
this.applicationStmt = applicationStmt;
}
+ /**
+ * JDBC 2.0
+ *
+ * Get a REF(<structured-type>) column.
+ *
+ * @param i the first column is 1, the second is 2, ...
+ * @return an object representing data of an SQL REF type
+ * @exception SQLException Feature not implemented for now.
+ */
+ public final Ref getRef(int i) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ /**
+ * JDBC 2.0
+ *
+ * Get an array column.
+ *
+ * @param i the first column is 1, the second is 2, ...
+ * @return an object representing an SQL array
+ * @exception SQLException Feature not implemented for now.
+ */
+ public final Array getArray(int i) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ /**
+ * JDBC 2.0
+ *
+ * Get a REF(<structured-type>) column.
+ *
+ * @param colName the column name
+ * @return an object representing data of an SQL REF type
+ * @exception SQLException Feature not implemented for now.
+ */
+ public final Ref getRef(String colName) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ /**
+ * JDBC 2.0
+ *
+ * Get an array column.
+ *
+ * @param colName the column name
+ * @return an object representing an SQL array
+ * @exception SQLException Feature not implemented for now.
+ */
+ public final Array getArray(String colName) throws SQLException {
+ throw Util.notImplemented();
+ }
+
//---------------------------------------------------------------------
// Traversal/Positioning
//---------------------------------------------------------------------
@@ -2581,6 +2766,35 @@ public abstract class EmbedResultSet ext
}
}
+ public void updateBigDecimal(int columnIndex, BigDecimal x)
+ throws SQLException {
+ try {
+ getDVDforColumnToBeUpdated(columnIndex, "updateBigDecimal").setBigDecimal(x);
+ } catch (StandardException t) {
+ throw noStateChangeException(t);
+ }
+ }
+
+ /**
+ * JDBC 2.0
+ *
+ * Update a column with a BigDecimal value.
+ *
+ * The updateXXX() methods are used to update column values in the current
+ * row, or the insert row. The updateXXX() methods do not update the
+ * underlying database, instead the updateRow() or insertRow() methods are
+ * called to update the database.
+ *
+ * @param columnName the name of the column
+ * @param x the new column value
+ * @exception SQLException if a database-access error occurs
+ */
+ public void updateBigDecimal(String columnName, BigDecimal x)
+ throws SQLException {
+ checkIfClosed("updateBigDecimal");
+ updateBigDecimal(findColumnName(columnName), x);
+ }
+
/**
* JDBC 2.0
*
@@ -3169,6 +3383,11 @@ public abstract class EmbedResultSet ext
return;
}
+ if (x instanceof BigDecimal) {
+ updateBigDecimal(columnIndex, (BigDecimal) x);
+ return;
+ }
+
if (x instanceof byte[]) {
updateBytes(columnIndex, (byte[]) x);
return;
@@ -5196,7 +5415,327 @@ public abstract class EmbedResultSet ext
checkIfClosed("updateClob");
updateClob(findColumnName(columnName), x);
}
+
+ /**
+ * JDBC 3.0
+ *
+ * Updates the designated column with a java.sql.Ref value. The updater
+ * methods are used to update column values in the current row or the insert
+ * row. The updater methods do not update the underlying database; instead
+ * the updateRow or insertRow methods are called to update the database.
+ *
+ * @param columnIndex - the first column is 1, the second is 2
+ * @param x - the new column value
+ * @exception SQLException Feature not implemented for now.
+ */
+ public void updateRef(int columnIndex, Ref x)
+ throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ /**
+ * JDBC 3.0
+ *
+ * Updates the designated column with a java.sql.Ref value. The updater
+ * methods are used to update column values in the current row or the insert
+ * row. The updater methods do not update the underlying database; instead
+ * the updateRow or insertRow methods are called to update the database.
+ *
+ * @param columnName - the SQL name of the column
+ * @param x - the new column value
+ * @exception SQLException Feature not implemented for now.
+ */
+ public void updateRef(String columnName, Ref x)
+ throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ /**
+ * JDBC 3.0
+ *
+ * Updates the designated column with a java.sql.Array value. The updater
+ * methods are used to update column values in the current row or the insert
+ * row. The updater methods do not update the underlying database; instead
+ * the updateRow or insertRow methods are called to update the database.
+ *
+ * @param columnIndex - the first column is 1, the second is 2
+ * @param x - the new column value
+ * @exception SQLException Feature not implemented for now.
+ */
+ public void updateArray(int columnIndex, Array x)
+ throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ /**
+ * JDBC 3.0
+ *
+ * Updates the designated column with a java.sql.Array value. The updater
+ * methods are used to update column values in the current row or the insert
+ * row. The updater methods do not update the underlying database; instead
+ * the updateRow or insertRow methods are called to update the database.
+ *
+ * @param columnName - the SQL name of the column
+ * @param x - the new column value
+ * @exception SQLException Feature not implemented for now.
+ */
+ public void updateArray(String columnName, Array x)
+ throws SQLException {
+ throw Util.notImplemented();
+ }
+ // JDBC 4.0 methods
+
+ public RowId getRowId(int columnIndex) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public RowId getRowId(String columnName) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public void updateNCharacterStream(int columnIndex, Reader x)
+ throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public void updateNCharacterStream(int columnIndex, Reader x, long length)
+ throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public void updateNCharacterStream(String columnName, Reader x)
+ throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public void updateNCharacterStream(String columnName, Reader x, long length)
+ throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public void updateNString(int columnIndex, String nString) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public void updateNString(String columnName, String nString) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public void updateNClob(int columnIndex, Reader reader)
+ throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public void updateNClob(String columnName, NClob nClob) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public void updateNClob(String columnName, Reader reader)
+ throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public Reader getNCharacterStream(int columnIndex) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public Reader getNCharacterStream(String columnName) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public NClob getNClob(int i) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public NClob getNClob(String colName) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public String getNString(int columnIndex) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public String getNString(String columnName) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public void updateRowId(int columnIndex, RowId x) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public void updateRowId(String columnName, RowId x) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public SQLXML getSQLXML(int columnIndex) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public SQLXML getSQLXML(String colName) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ public void updateSQLXML(String columnName, SQLXML xmlObject) throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ /**
+ * Returns false unless
+ * <code>interfaces</code> is implemented
+ *
+ * @param interfaces a Class defining an interface.
+ * @return true if this implements the interface or directly or indirectly
+ * wraps an object that does.
+ * @throws java.sql.SQLException if an error occurs while determining
+ * whether this is a wrapper for an object with the given interface.
+ */
+ public boolean isWrapperFor(Class<?> interfaces) throws SQLException {
+ checkIfClosed("isWrapperFor");
+ return interfaces.isInstance(this);
+ }
+
+ /**
+ * Returns
+ * <code>this</code> if this class implements the interface
+ *
+ * @param interfaces a Class defining an interface
+ * @return an object that implements the interface
+ * @throws java.sql.SQLExption if no object if found that implements the
+ * interface
+ */
+ public <T> T unwrap(java.lang.Class<T> interfaces)
+ throws SQLException {
+ checkIfClosed("unwrap");
+ //Derby does not implement non-standard methods on
+ //JDBC objects
+ //hence return this if this class implements the interface
+ //or throw an SQLException
+ try {
+ return interfaces.cast(this);
+ } catch (ClassCastException cce) {
+ throw newSQLException(SQLState.UNABLE_TO_UNWRAP, interfaces);
+ }
+ }
+
+ /**
+ *
+ * Updates the designated column using the given Reader object, which is the
+ * given number of characters long.
+ *
+ * @param columnIndex - the first column is 1, the second is 2
+ * @param x - the new column value
+ * @param length - the length of the stream
+ *
+ * @exception SQLException Feature not implemented for now.
+ */
+ public void updateNClob(int columnIndex, Reader x, long length)
+ throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ /**
+ * Updates the designated column using the given Reader object, which is the
+ * given number of characters long.
+ *
+ * @param columnName - the Name of the column to be updated
+ * @param x - the new column value
+ * @param length - the length of the stream
+ *
+ * @exception SQLException Feature not implemented for now.
+ *
+ */
+ public void updateNClob(String columnName, Reader x, long length)
+ throws SQLException {
+ throw Util.notImplemented();
+ }
+
+ ////////////////////////////////////////////////////////////////////
+ //
+ // INTRODUCED BY JDBC 4.1 IN JAVA 7
+ //
+ ////////////////////////////////////////////////////////////////////
+
+ /**
+ * Retrieve the column as an object of the desired type.
+ */
+ public <T> T getObject(int columnIndex, Class<T> type)
+ throws SQLException {
+ checkIfClosed("getObject");
+
+ if (type == null) {
+ throw mismatchException("NULL", columnIndex);
+ }
+
+ Object retval;
+
+ if (String.class.equals(type)) {
+ retval = getString(columnIndex);
+ } else if (BigDecimal.class.equals(type)) {
+ retval = getBigDecimal(columnIndex);
+ } else if (Boolean.class.equals(type)) {
+ retval = getBoolean(columnIndex);
+ } else if (Byte.class.equals(type)) {
+ retval = getByte(columnIndex);
+ } else if (Short.class.equals(type)) {
+ retval = getShort(columnIndex);
+ } else if (Integer.class.equals(type)) {
+ retval = getInt(columnIndex);
+ } else if (Long.class.equals(type)) {
+ retval = getLong(columnIndex);
+ } else if (Float.class.equals(type)) {
+ retval = getFloat(columnIndex);
+ } else if (Double.class.equals(type)) {
+ retval = getDouble(columnIndex);
+ } else if (Date.class.equals(type)) {
+ retval = getDate(columnIndex);
+ } else if (Time.class.equals(type)) {
+ retval = getTime(columnIndex);
+ } else if (Timestamp.class.equals(type)) {
+ retval = getTimestamp(columnIndex);
+ } else if (Blob.class.equals(type)) {
+ retval = getBlob(columnIndex);
+ } else if (Clob.class.equals(type)) {
+ retval = getClob(columnIndex);
+ } else if (type.isArray() && type.getComponentType().equals(byte.class)) {
+ retval = getBytes(columnIndex);
+ } else {
+ retval = getObject(columnIndex);
+ }
+
+ if (wasNull()) {
+ retval = null;
+ }
+
+ if ((retval == null) || (type.isInstance(retval))) {
+ return type.cast(retval);
+ }
+
+ throw mismatchException(type.getName(), columnIndex);
+ }
+
+ private SQLException mismatchException(String targetTypeName, int columnIndex)
+ throws SQLException {
+ String sourceTypeName = getMetaData().getColumnTypeName(columnIndex);
+ return newSQLException(SQLState.LANG_DATA_TYPE_GET_MISMATCH,
+ targetTypeName, sourceTypeName);
+ }
+
+ public <T> T getObject(String columnName, Class<T> type)
+ throws SQLException {
+ checkIfClosed("getObject");
+ return getObject(findColumn(columnName), type);
+ }
+
+
/*
* @see org.apache.derby.iapi.jdbc.EngineResultSet#isNull(int)
*/
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet42.java?rev=1493707&r1=1493706&r2=1493707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet42.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet42.java Mon Jun 17 10:12:42 2013
@@ -23,16 +23,13 @@ package org.apache.derby.impl.jdbc;
import org.apache.derby.iapi.sql.ResultSet;
-import java.sql.JDBCType;
import java.sql.SQLException;
import java.sql.SQLType;
-import org.apache.derby.iapi.reference.SQLState;
-
/**
* JDBC 4.2 specific methods that cannot be implemented in superclasses.
*/
-public class EmbedResultSet42 extends org.apache.derby.impl.jdbc.EmbedResultSet40
+public class EmbedResultSet42 extends EmbedResultSet
{
/** Creates a new instance of EmbedResultSet42 */
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java?rev=1493707&r1=1493706&r2=1493707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java Mon Jun 17 10:12:42 2013
@@ -22,20 +22,15 @@
package org.apache.derby.impl.jdbc;
import org.apache.derby.iapi.services.io.ArrayUtil;
-import org.apache.derby.iapi.sql.ResultDescription;
import org.apache.derby.iapi.sql.ResultColumnDescriptor;
import org.apache.derby.iapi.types.DataTypeDescriptor;
import org.apache.derby.iapi.types.DataTypeUtilities;
-import org.apache.derby.iapi.types.TypeId;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
import org.apache.derby.iapi.reference.SQLState;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Types;
-import java.sql.ResultSet;
/**
* A ResultSetMetaData object can be used to find out about the types
@@ -57,8 +52,7 @@ import java.sql.ResultSet;
this sharing must be removed.
*
*/
-public abstract class EmbedResultSetMetaData
- implements ResultSetMetaData {
+public class EmbedResultSetMetaData implements ResultSetMetaData {
private final ResultColumnDescriptor[] columnInfo;
@@ -388,4 +382,35 @@ public abstract class EmbedResultSetMeta
public static ResultColumnDescriptor getResultColumnDescriptor(String name, DataTypeDescriptor dtd) {
return new org.apache.derby.impl.sql.GenericColumnDescriptor(name, dtd);
}
+
+ // JDBC 4.0 - java.sql.Wrapper interface
+
+ /**
+ * Returns whether or not this instance implements the specified interface.
+ *
+ * @param iface the interface to check for
+ * @return true if this implements the interface
+ */
+ public final boolean isWrapperFor(Class<?> iface) {
+ return iface.isInstance(this);
+ }
+
+ /**
+ * Returns {@code this} if this class implements the interface.
+ *
+ * @param iface the interface
+ * @return an object that implements the interface
+ * @throws SQLException if no object is found that implements the
+ * interface
+ */
+ public final <T> T unwrap(Class<T> iface) throws SQLException {
+ // Derby does not implement non-standard methods on JDBC objects,
+ // hence return this if this class implements the interface
+ // or throw an SQLException.
+ try {
+ return iface.cast(this);
+ } catch (ClassCastException cce) {
+ throw Util.generateCsSQLException(SQLState.UNABLE_TO_UNWRAP, iface);
+ }
+ }
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java?rev=1493707&r1=1493706&r2=1493707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java Mon Jun 17 10:12:42 2013
@@ -29,12 +29,11 @@ import org.apache.derby.iapi.sql.ResultS
import org.apache.derby.impl.jdbc.EmbedCallableStatement;
import org.apache.derby.impl.jdbc.EmbedConnection;
import org.apache.derby.impl.jdbc.EmbedConnection40;
+import org.apache.derby.impl.jdbc.EmbedDatabaseMetaData;
import org.apache.derby.impl.jdbc.EmbedPreparedStatement;
import org.apache.derby.impl.jdbc.EmbedResultSet;
-import org.apache.derby.impl.jdbc.EmbedResultSet40;
+import org.apache.derby.impl.jdbc.EmbedResultSetMetaData;
import org.apache.derby.impl.jdbc.EmbedStatement;
-import org.apache.derby.impl.jdbc.EmbedDatabaseMetaData40;
-import org.apache.derby.impl.jdbc.EmbedResultSetMetaData40;
import org.apache.derby.iapi.jdbc.ResourceAdapter;
import org.apache.derby.impl.jdbc.Util;
import java.sql.Connection;
@@ -128,26 +127,26 @@ public class Driver40 extends Driver30 {
}
public EmbedResultSet newEmbedResultSet(EmbedConnection conn, ResultSet results, boolean forMetaData, org.apache.derby.impl.jdbc.EmbedStatement statement,boolean isAtomic) throws SQLException {
- return new EmbedResultSet40(conn, results, forMetaData, statement,
+ return new EmbedResultSet(conn, results, forMetaData, statement,
isAtomic);
}
public DatabaseMetaData newEmbedDatabaseMetaData(EmbedConnection conn, String dbname)
throws SQLException {
- return new EmbedDatabaseMetaData40(conn,dbname);
+ return new EmbedDatabaseMetaData(conn, dbname);
}
- /**
- * Returns a new java.sql.ResultSetMetaData for this implementation
- *
- * @param columnInfo a ResultColumnDescriptor that stores information
- * about the columns in a ResultSet
- * @return ResultSetMetaData
- */
- public EmbedResultSetMetaData40 newEmbedResultSetMetaData
- (ResultColumnDescriptor[] columnInfo) {
- return new EmbedResultSetMetaData40(columnInfo);
- }
+ /**
+ * Returns a new java.sql.ResultSetMetaData for this implementation
+ *
+ * @param columnInfo a ResultColumnDescriptor that stores information about
+ * the columns in a ResultSet
+ * @return ResultSetMetaData
+ */
+ public EmbedResultSetMetaData newEmbedResultSetMetaData(
+ ResultColumnDescriptor[] columnInfo) {
+ return new EmbedResultSetMetaData(columnInfo);
+ }
/**
* Create and return an EmbedPooledConnection from the received instance
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41.java?rev=1493707&r1=1493706&r2=1493707&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41.java Mon Jun 17 10:12:42 2013
@@ -27,7 +27,7 @@ import org.apache.derby.client.am.Client
import org.apache.derby.client.am.LogicalCallableStatement;
import org.apache.derby.iapi.jdbc.BrokeredCallableStatement40;
import org.apache.derby.impl.jdbc.EmbedCallableStatement;
-import org.apache.derby.impl.jdbc.EmbedResultSet40;
+import org.apache.derby.impl.jdbc.EmbedResultSet;
/**
* A wrapper around the getObject() overloads added by JDBC 4.1.
@@ -42,7 +42,7 @@ public class Wrapper41
//
///////////////////////////////////////////////////////////////////////
- private EmbedResultSet40 _embedded;
+ private EmbedResultSet _embedded;
private ClientResultSet _netclient;
private EmbedCallableStatement _embedCallableStatement;
private ClientCallableStatement _callableStatement;
@@ -57,7 +57,7 @@ public class Wrapper41
public Wrapper41( Object wrapped ) throws Exception
{
- if ( wrapped instanceof EmbedResultSet40 ) { _embedded = (EmbedResultSet40) wrapped; }
+ if ( wrapped instanceof EmbedResultSet ) { _embedded = (EmbedResultSet) wrapped; }
else if ( wrapped instanceof EmbedCallableStatement ) { _embedCallableStatement = (EmbedCallableStatement) wrapped; }
else if ( wrapped instanceof BrokeredCallableStatement40 ) { _brokeredCallableStatement = (BrokeredCallableStatement40) wrapped; }
else if ( wrapped instanceof ClientResultSet ) { _netclient = (ClientResultSet) wrapped; }