On 4/10/05, Mamta Satoor <[EMAIL PROTECTED]> wrote:
> On Apr 6, 2005 9:44 PM, Mamta Satoor <[EMAIL PROTECTED]> wrote:
> > On Apr 5, 2005 2:50 PM, Mamta Satoor <[EMAIL PROTECTED]> wrote:
> > > I guess, it will help to actually attach the patch.
> > >
> > > thanks,
> > > Mamta
> > >
> > > On Apr 5, 2005 1:40 PM, Mamta Satoor <[EMAIL PROTECTED]> wrote:
> > > > Hi,
> > > >
> > > > I have sent 2 patches for Derby engine code in the past(and they are
> > > > already commited) in preparation for making updatable resultset
> > > > functionality available in Network Server mode. Here is another patch
> > > > to make progress towards that goal.
> > > >
> > > > The problem is that Derby does not return correct values for
> > > > ResultSetMetaData.getSchemaName and ResultSetMetaData.isWritable. And
> > > > these 2 methods are crucial to have updatable resultset functionality
> > > > under Network Server mode.
> > > >
> > > > Following is the description of the issue from Jira
> > > > "Derby Net Client and JCC driver rely on getSchemanName method to
> > > > construct the correct "update where current of sql" for an updatRow.
> > > > For eg, if the user is in say schema s1 and the updatable resultset is
> > > > issued on a table from schema s2 with the sql "select c11 from s2.t1
> > > > for update". Currenly, getSchemaName returns null and hence, the
> > > > client code constructs a sql like "update t1 ... where current of
> > > > ...". ie the update is being issued against table t1 in schema s1.
> > > > getSchemaName should return s2, so the driver can correctly genereat
> > > > sql as "update s2.t1 ... where current of ...".
> > > >
> > > > In addition, the client code lets a user issue an updateXXX on a
> > > > column only if the column is writable and it determines that by
> > > > looking at the return value of isWritable(). Derby engine currently
> > > > always returns false for this method and because of that, updateXXX
> > > > fails in Network Server mode. Derby should return true for the columns
> > > > which can be updated in the given resultset. For eg for "select c11,
> > > > c12 from t1 for update of c11", isWritable should return true for c11
> > > > and false for c12. "
> > > >
> > > > Most of the changes in this patch are to add methods and variables
> > > > related to schema name and writable status to columns so they are
> > > > available correctly to EmbedResultSetMetaData.java. These changes went
> > > > into ResultColumn.java, VirtualColumnNode.java, BaseColumnNode.java,
> > > > ColumnReference.java, ValueNode.java, GenericColumnDescriptor.java,
> > > > ColumnDescriptor.java, ResultColumnDescriptor.java
> > > >
> > > > CursorNode.java currently marks the columns updatable in FromTable
> > > > object only. The columns need to be marked correctly in
> > > > ResultSetColumnList associated with the cursor also. That is what the
> > > > change in CursorNode.java does.
> > > >
> > > > ResultColumnList.java currently doesn't handle marking columns
> > > > updatable for the column list associated with a cursor node. Added
> > > > markColumnsInSelectListUpdatableByCursor method to handle that.
> > > >
> > > > Change in EmbedResultSet.java is to catch updateXXX on read-only
> > > > columns of the resultset. Have added test for this.
> > > >
> > > > Change in EmbedResultSetMetaData.java is have isWritable method return
> > > > the column's updatableByCursor state. And to call the correct schema
> > > > name method on the column in getSchemaName method.
> > > >
> > > > svn stat
> > > > M java\engine\org\apache\derby\impl\sql\compile\ResultColumn.java
> > > > M
> > > > java\engine\org\apache\derby\impl\sql\compile\VirtualColumnNode.java
> > > > M java\engine\org\apache\derby\impl\sql\compile\CursorNode.java
> > > > M java\engine\org\apache\derby\impl\sql\compile\BaseColumnNode.java
> > > > M
> > > > java\engine\org\apache\derby\impl\sql\compile\ColumnReference.java
> > > > M java\engine\org\apache\derby\impl\sql\compile\ValueNode.java
> > > > M
> > > > java\engine\org\apache\derby\impl\sql\compile\ResultColumnList.java
> > > > M
> > > > java\engine\org\apache\derby\impl\sql\GenericColumnDescriptor.java
> > > > M java\engine\org\apache\derby\impl\jdbc\EmbedResultSet.java
> > > > M
> > > > java\engine\org\apache\derby\impl\jdbc\EmbedResultSetMetaData.java
> > > > M
> > > > java\engine\org\apache\derby\iapi\sql\dictionary\ColumnDescriptor.java
> > > > M java\engine\org\apache\derby\iapi\sql\ResultColumnDescriptor.java
> > > > M
> > > > java\testing\org\apache\derbyTesting\functionTests\tests\lang\updatableResultSet.java
> > > > M
> > > > java\testing\org\apache\derbyTesting\functionTests\master\DerbyNet\updatableResultSet.out
> > > > M
> > > > java\testing\org\apache\derbyTesting\functionTests\master\DerbyNet\resultset.out
> > > > M
> > > > java\testing\org\apache\derbyTesting\functionTests\master\DerbyNetClient\updatableResultSet.out
> > > > M
> > > > java\testing\org\apache\derbyTesting\functionTests\master\DerbyNetClient\resultset.out
> > > > M
> > > > java\testing\org\apache\derbyTesting\functionTests\master\updatableResultSet.out
> > > > M
> > > > java\testing\org\apache\derbyTesting\functionTests\master\jdk14\updatableResultSet.out
> > > > M
> > > > java\testing\org\apache\derbyTesting\functionTests\master\resultset.out
> > > >
> > > > If no objection from anyone, can a commiter commit this patch?
> > > >
> > > > thanks,
> > > > Mamta
> > > >
> > >
> > >
> > >
> >
> > Hi,
> >
> > If the changes look good, can a commiter please commit this patch for me?
> >
> > thanks,
> > Mamta
> >
>
> Hi,
>
> Can a commiter please commit this?
>
> thanks,
> Mamta
>
Hi,
Both Kathey and Satheesh seem to have trouble applying the patch I
last submitted and have asked me to resubmit a new patch. I have
synced up to the latest source and made some minor comment changes.
Can someone other than Kathey and Satheesh also try to apply this
latest patch to see if it applies fine on their system?
svn stat
M java\engine\org\apache\derby\impl\sql\compile\ResultColumn.java
M java\engine\org\apache\derby\impl\sql\compile\VirtualColumnNode.java
M java\engine\org\apache\derby\impl\sql\compile\CursorNode.java
M java\engine\org\apache\derby\impl\sql\compile\BaseColumnNode.java
M java\engine\org\apache\derby\impl\sql\compile\ColumnReference.java
M java\engine\org\apache\derby\impl\sql\compile\ValueNode.java
M java\engine\org\apache\derby\impl\sql\compile\ResultColumnList.java
M java\engine\org\apache\derby\impl\sql\GenericColumnDescriptor.java
M java\engine\org\apache\derby\impl\jdbc\EmbedResultSet.java
M java\engine\org\apache\derby\impl\jdbc\EmbedResultSetMetaData.java
M java\engine\org\apache\derby\iapi\sql\dictionary\ColumnDescriptor.java
M java\engine\org\apache\derby\iapi\sql\ResultColumnDescriptor.java
M
java\testing\org\apache\derbyTesting\functionTests\tests\lang\updatableResultSet.java
M
java\testing\org\apache\derbyTesting\functionTests\master\DerbyNet\updatableResultSet.out
M
java\testing\org\apache\derbyTesting\functionTests\master\DerbyNet\resultset.out
M
java\testing\org\apache\derbyTesting\functionTests\master\DerbyNetClient\updatableResultSet.out
M
java\testing\org\apache\derbyTesting\functionTests\master\DerbyNetClient\resultset.out
M
java\testing\org\apache\derbyTesting\functionTests\master\updatableResultSet.out
M
java\testing\org\apache\derbyTesting\functionTests\master\jdk14\updatableResultSet.out
M java\testing\org\apache\derbyTesting\functionTests\master\resultset.out
Thanks,
Mamta
Index: java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
===================================================================
--- java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
(revision 161347)
+++ java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
(working copy)
@@ -85,6 +85,10 @@
String exposedName;
String tableName;
String sourceTableName;
+ //schema name for result column. Used by JCC to determine the
schemaname.tablename that's the target for update...where current of cursorname
sql.
+ //Without the schema name, for "select * from s1.t1 for update", JCC
generates "update t1 ... where current of cursorname"
+ //That is incorrect because update is trying to go against table t1 in
the current schema rather than table t1 in schema s1.
+ String sourceSchemaName;
ValueNode expression;
ColumnDescriptor columnDescriptor;
boolean isGenerated;
@@ -215,7 +219,7 @@
return exposedName;
}
- public String getSchemaName()
+ public String getSchemaName() throws StandardException
{
if ((columnDescriptor!=null) &&
(columnDescriptor.getTableDescriptor() != null))
@@ -256,6 +260,14 @@
}
/**
+ * @see ResultColumnDescriptor#getSourceSchemaName
+ */
+ public String getSourceSchemaName()
+ {
+ return sourceSchemaName;
+ }
+
+ /**
* Clear the table name for the underlying ColumnReference.
* See UpdateNode for full explaination.
*/
@@ -274,14 +286,14 @@
public DataTypeDescriptor getExpressionType()
{
- return (expression == null) ?
+ return (expression == null) ?
dataTypeServices :
expression.getTypeServices();
}
public int getColumnPosition()
{
- if (columnDescriptor!=null)
+ if (columnDescriptor!=null)
return columnDescriptor.getPosition();
else
return virtualColumnId;
@@ -785,6 +797,7 @@
ColumnReference cr = (ColumnReference) expression;
tableName = cr.getTableName();
sourceTableName = cr.getSourceTableName();
+ sourceSchemaName = cr.getSourceSchemaName();
}
}
@@ -1335,11 +1348,11 @@
}
/**
- * Tell whether this column is updatable bay a positioned update.
+ * Tell whether this column is updatable by a positioned update.
*
* @return true means this column is updatable
*/
- boolean updatableByCursor()
+ public boolean updatableByCursor()
{
return updatableByCursor;
}
Index: java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java
===================================================================
--- java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java
(revision 161347)
+++ java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java
(working copy)
@@ -123,6 +123,40 @@
}
/**
+ * Get the name of the table the ResultColumn is in, if any.
+ *
+ * @return A String containing the name of the table the Column
+ * is in. If the column is not in a table (i.e. is a
+ * derived column), it returns NULL.
+ */
+ public String getTableName()
+ {
+ return ( ( sourceColumn != null) ? sourceColumn.getTableName()
: null );
+ }
+
+ /**
+ * Get the name of the schema the ResultColumn's table is in, if any.
+ *
+ * @return A String containing the name of the schema for the
Column's table.
+ * If the column is not in a schema (i.e. is a derived
column), it returns NULL.
+ */
+ public String getSchemaName() throws StandardException
+ {
+ return ( ( sourceColumn != null) ? sourceColumn.getSchemaName()
: null );
+ }
+
+ /**
+ * Return whether or not the ResultColumn is wirtable by a positioned
update.
+ *
+ * @return TRUE, if the column is a base column of a table and is a
+ * writable by a positioned update.
+ */
+ public boolean updatableByCursor()
+ {
+ return ( ( sourceColumn != null) ?
sourceColumn.updatableByCursor() : false );
+ }
+
+ /**
* Return the ResultColumn that is the source of this VirtualColumnNode.
*
* @return ResultSetNode
Index: java/engine/org/apache/derby/impl/sql/compile/CursorNode.java
===================================================================
--- java/engine/org/apache/derby/impl/sql/compile/CursorNode.java
(revision 161347)
+++ java/engine/org/apache/derby/impl/sql/compile/CursorNode.java
(working copy)
@@ -295,7 +295,7 @@
if (updateMode == READ_ONLY)
updatableColumns = null; // don't need them any
more
}
-
+
// bind the update columns
if (updateMode == UPDATE)
{
@@ -308,6 +308,9 @@
if (updateTable instanceof FromTable)
{
((FromTable)
updateTable).markUpdatableByCursor(updatableColumns);
+ //make sure that alongwith the FromTable, we
keep other ResultSetLists in correct state too.
+ //ResultSetMetaData.isWritable looks at this to
return the correct value.
+
resultSet.getResultColumns().markColumnsInSelectListUpdatableByCursor(updatableColumns);
}
}
Index: java/engine/org/apache/derby/impl/sql/compile/BaseColumnNode.java
===================================================================
--- java/engine/org/apache/derby/impl/sql/compile/BaseColumnNode.java
(revision 161347)
+++ java/engine/org/apache/derby/impl/sql/compile/BaseColumnNode.java
(working copy)
@@ -122,6 +122,16 @@
}
/**
+ * Get the schema name for this column's table
+ *
+ * @return The schema name for this column's table
+ */
+ public String getSchemaName() throws StandardException
+ {
+ return ( ( tableName != null) ? tableName.getSchemaName() :
null );
+ }
+
+ /**
* Do the code generation for this node. Should never be called.
*
* @param acb The ExpressionClassBuilder for the class being built
Index: java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
===================================================================
--- java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
(revision 161347)
+++ java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
(working copy)
@@ -502,17 +502,40 @@
/**
* Get the name of the table this column comes from.
*
- * @return The name of the table that this column comes from.
+ * @return The name of the table that this column comes from.
* Null if not a ColumnReference.
*/
public String getSourceTableName()
{
- return ( ( tableName != null) ? tableName.getTableName() :
+ return ( ( tableName != null) ? tableName.getTableName() :
((source != null) ?
source.getTableName() : null));
}
/**
+ * Get the name of the schema for the Column's table, if any.
+ *
+ * @return A String containing the name of the schema of the
Column's table.
+ * If the column is not in a schema (i.e. is a derived
column), it returns NULL.
+ */
+ public String getSourceSchemaName() throws StandardException
+ {
+ return ( ( tableName != null) ? tableName.getSchemaName() :
+ ((source != null) ?
source.getSchemaName() : null));
+ }
+
+ /**
+ * Is the column wirtable by the cursor or not. (ie, is it in the list
of FOR UPDATE columns list)
+ *
+ * @return TRUE, if the column is a base column of a table and is a
+ * writable by cursor.
+ */
+ public boolean updatableByCursor()
+ {
+ return ((source != null) ? source.updatableByCursor() : false);
+ }
+
+ /**
Return the table name as the node it is.
@return the column's table name.
*/
Index: java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
===================================================================
--- java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
(revision 161347)
+++ java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
(working copy)
@@ -670,13 +670,13 @@
*
* @return the default schema name for an expression -- null
*/
- public String getSchemaName()
+ public String getSchemaName() throws StandardException
{
return null;
}
/**
- * @return the default schema name for an expression -- null
+ * @return the default table name for an expression -- null
*/
public String getTableName()
{
@@ -684,6 +684,14 @@
}
/**
+ * @return the default updatability for an expression - false
+ */
+ public boolean updatableByCursor()
+ {
+ return false;
+ }
+
+ /**
* This is null so that the caller will substitute in the resultset
generated
* name as needed.
*
Index: java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
===================================================================
--- java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
(revision 161347)
+++ java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
(working copy)
@@ -262,6 +262,26 @@
return null;
}
+ //It's possible that there is a correlation name being used for the
column name. Because of that, when looking for the
+ //column name match in a SELECT statement's result column list, we
should look at the result column's expression which keeps
+ //the base column name. For eg, in the sql below, when looking for c11,
we will find it in the expression
+ //eg select 1, c11 as a1, c12 from s2.t1 for update of c11
+ ResultColumn getResultColumnThroughExpression(String columnName)
+ {
+ int size = size();
+ for (int index = 0; index < size; index++)
+ {
+ ResultColumn resultColumn = (ResultColumn)
elementAt(index);
+ if (columnName.equals(
resultColumn.expression.getColumnName()) )
+ {
+ /* Mark ResultColumn as referenced and return
it */
+ resultColumn.setReferenced();
+ return resultColumn;
+ }
+ }
+ return null;
+ }
+
/**
* Get a ResultColumn that matches the specified columnName and
* mark the ResultColumn as being referenced.
@@ -2437,7 +2457,7 @@
}
/**
- * Mark all the columns in this list as updatable by a positioned update
+ * Mark all the (base) columns in this list as updatable by a
positioned update
* statement. This is necessary
* for positioned update statements, because we expand the column list
* to include all the columns in the base table, and we need to be able
@@ -2453,7 +2473,9 @@
for (int index = 0; index < size; index++)
{
- ((ResultColumn)
elementAt(index)).markUpdatableByCursor();
+ //determine if the column is a base column and not a
derived column
+ if (((ResultColumn)
elementAt(index)).getSourceTableName() != null)
+ ((ResultColumn)
elementAt(index)).markUpdatableByCursor();
}
}
@@ -2630,17 +2652,28 @@
}
/**
- * Mark as updatable all the columns in this result column list
- * that match the columns in the given update column list
+ * Mark all the columns in the select sql that this result column list
represents
+ * as updatable if they match the columns in the given update column
list.
*
* @param updateColumns A Vector representing the columns
* to be updated.
*/
- void markUpdatableByCursor(Vector updateColumns)
+ void markColumnsInSelectListUpdatableByCursor(Vector updateColumns)
{
+ commonCodeForUpdatableByCursor(updateColumns, true);
+ }
+
+ //dealingWithSelectResultColumnList true means we are dealing with
ResultColumnList for a select sql.
+ //When dealing with ResultColumnList for select sql, it is possible
that not all the updatable columns are
+ //projected in the select column list and hence it is possible that we
may not find the column to be updated
+ //in the ResultColumnList and that is why special handling is required
when dealingWithSelectResultColumnList is true.
+ //eg select c11, c13 from t1 for update of c11, c12
+ //In the eg above, we will find updatable column c11 in the select
column list but we will not find updatable column c12 in the select column list
+ private void commonCodeForUpdatableByCursor(Vector updateColumns,
boolean dealingWithSelectResultColumnList)
+ {
/*
- ** If there is no update column list, or the list is empty,
- ** it means all the columns are updatable.
+ ** If there is no update column list, or the list is empty,
then it means that
+ ** all the columns which have a base table associated with them
are updatable.
*/
if ( (updateColumns == null) || (updateColumns.size() == 0) )
{
@@ -2654,26 +2687,36 @@
for (int index = 0; index < ucSize; index++)
{
- columnName = (String)
updateColumns.elementAt(index);
+ columnName = (String)
updateColumns.elementAt(index);
resultColumn = getResultColumn(columnName);
-
if (SanityManager.DEBUG)
{
- if (resultColumn == null)
+ if (resultColumn == null &&
!dealingWithSelectResultColumnList)
{
- SanityManager.THROWASSERT(
- "No result column found
with name " +
- columnName);
+ SanityManager.THROWASSERT("No
result column found with name " + columnName);
}
}
-
+ if (resultColumn == null &&
dealingWithSelectResultColumnList)
+ continue; //this means the column
specified in FOR UPDATE clause is not part of the select list
resultColumn.markUpdatableByCursor();
}
}
}
/**
+ * Mark as updatable all the columns in this result column list
+ * that match the columns in the given update column list
+ *
+ * @param updateColumns A Vector representing the columns
+ * to be updated.
+ */
+ void markUpdatableByCursor(Vector updateColumns)
+ {
+ commonCodeForUpdatableByCursor(updateColumns, false);
+ }
+
+ /**
* Returns true if the given column position is for a column that will
* be or could be updated by the positioned update of a cursor.
*
Index: java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java
===================================================================
--- java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java
(revision 161347)
+++ java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java
(working copy)
@@ -66,6 +66,7 @@
private int columnPos;
private DataTypeDescriptor type;
private boolean isAutoincrement;
+ private boolean updatableByCursor;
/**
* Niladic constructor for Formatable
@@ -92,10 +93,11 @@
{
name = rcd.getName();
tableName = rcd.getSourceTableName();
- schemaName = rcd.getSchemaName();
+ schemaName = rcd.getSourceSchemaName();
columnPos = rcd.getColumnPosition();
type = rcd.getType();
isAutoincrement = rcd.isAutoincrement();
+ updatableByCursor = rcd.updatableByCursor();
}
/**
@@ -127,7 +129,7 @@
* is in. If the column is not in a schema (i.e. is a
* derived column), it returns NULL.
*/
- public String getSchemaName()
+ public String getSourceSchemaName()
{
return schemaName;
}
@@ -161,6 +163,11 @@
return isAutoincrement;
}
+ public boolean updatableByCursor()
+ {
+ return updatableByCursor;
+ }
+
//////////////////////////////////////////////
//
// FORMATABLE
@@ -182,6 +189,7 @@
fh.putInt("columnPos", columnPos);
fh.put("type", type);
fh.putBoolean("isAutoincrement", isAutoincrement);
+ fh.putBoolean("updatableByCursor", updatableByCursor);
out.writeObject(fh);
return;
}
@@ -205,6 +213,7 @@
columnPos = fh.getInt("columnPos");
type = (DataTypeDescriptor)fh.get("type");
isAutoincrement = fh.getBoolean("isAutoincrement");
+ updatableByCursor = fh.getBoolean("updatableByCursor");
}
/**
Index: java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
===================================================================
--- java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java (revision
161347)
+++ java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java (working copy)
@@ -2048,6 +2048,11 @@
//2)Make sure the column corresponds to a column in the base table and
it is not a derived column
if (rd.getColumnDescriptor(columnIndex).getSourceTableName() == null)
throw Util.generateCsSQLException(SQLState.COLUMN_NOT_FROM_BASE_TABLE,
methodName);
+
+ //3)If column not updatable then throw an exception
+ if (!getMetaData().isWritable(columnIndex))
+ throw
Util.generateCsSQLException(SQLState.LANG_COLUMN_NOT_UPDATABLE_IN_CURSOR,
+
theResults.getResultDescription().getColumnDescriptor(columnIndex).getName(),
getCursorName());
}
//do following few checks before accepting updatable resultset api
@@ -3153,6 +3158,8 @@
boolean foundOneColumnAlready = false;
StringBuffer updateWhereCurrentOfSQL = new StringBuffer("UPDATE ");
CursorActivation activation =
getEmbedConnection().getLanguageConnection().lookupCursorActivation(getCursorName());
+
+
ExecCursorTableReference targetTable =
activation.getPreparedStatement().getTargetTable();
updateWhereCurrentOfSQL.append(getFullBaseTableName(targetTable));//got the
underlying (schema.)table name
updateWhereCurrentOfSQL.append(" SET ");
Index: java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java
===================================================================
--- java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java
(revision 161347)
+++ java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java
(working copy)
@@ -204,7 +204,7 @@
public String getSchemaName(int column) throws SQLException {
ResultColumnDescriptor cd = columnInfo[column - 1];
- String s = cd.getSchemaName();
+ String s = cd.getSourceSchemaName();
// database returns null when no schema name to differentiate
from empty name
return (s==null? "" : s);
}
@@ -308,9 +308,7 @@
*/
public boolean isWritable(int column) throws SQLException {
validColumnNumber(column);
-
- // we just don't know if it is a base table column or not
- return false;
+ return columnInfo[column - 1].updatableByCursor();
}
/**
Index: java/engine/org/apache/derby/iapi/sql/dictionary/ColumnDescriptor.java
===================================================================
--- java/engine/org/apache/derby/iapi/sql/dictionary/ColumnDescriptor.java
(revision 161347)
+++ java/engine/org/apache/derby/iapi/sql/dictionary/ColumnDescriptor.java
(working copy)
@@ -326,6 +326,10 @@
{
return (autoincInc != 0);
}
+ public boolean updatableByCursor()
+ {
+ return false;
+ }
/**
* Get the start value of an autoincrement column
Index: java/engine/org/apache/derby/iapi/sql/ResultColumnDescriptor.java
===================================================================
--- java/engine/org/apache/derby/iapi/sql/ResultColumnDescriptor.java
(revision 161347)
+++ java/engine/org/apache/derby/iapi/sql/ResultColumnDescriptor.java
(working copy)
@@ -47,24 +47,32 @@
String getName();
/**
- * Get the name of the schema the Column is in, if any.
+ * Get the name of the schema the Column's table is in, if any.
*
- * @return A String containing the name of the schema the Column
- * is in. If the column is not in a schema (i.e. is a
+ * @return A String containing the name of the schema to which
Column's
+ * table belongs. If the column is not from a table (i.e.
is a
* derived column), it returns NULL.
*/
- String getSchemaName();
+ String getSourceSchemaName();
/**
* Get the name of the table the Column is in, if any.
*
- * @return A String containing the name of the table the Column
+ * @return A String containing the name of the table of the Column
* is in. If the column is not in a table (i.e. is a
* derived column), it returns NULL.
*/
String getSourceTableName();
/**
+ * Return true if the column is wirtable by a positioned update.
+ *
+ * @return TRUE, if the column is a base column of a table and is a
+ * writable by a positioned update.
+ */
+ boolean updatableByCursor();
+
+ /**
* Get the position of the Column.
* NOTE - position is 1-based.
*
Index:
java/testing/org/apache/derbyTesting/functionTests/tests/lang/updatableResultSet.java
===================================================================
---
java/testing/org/apache/derbyTesting/functionTests/tests/lang/updatableResultSet.java
(revision 161347)
+++
java/testing/org/apache/derbyTesting/functionTests/tests/lang/updatableResultSet.java
(working copy)
@@ -1,3 +1,4 @@
+<<<<<<< .mine
/*
Derby - Class org.apache.derbyTesting.functionTests.lang.updatableResultSet
@@ -33,7 +34,2496 @@
import org.apache.derby.tools.ij;
import org.apache.derby.tools.JDBCDisplayUtil;
+import org.apache.derby.iapi.services.info.JVMInfo;
import org.apache.derbyTesting.functionTests.util.TestUtil;
+
+import java.math.BigDecimal;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+
+/**
+ This tests JDBC 2.0 updateable resutlset - deleteRow, updateRow api
+ */
+public class updatableResultSet {
+
+ private static Connection conn;
+ private static DatabaseMetaData dbmt;
+ private static Statement stmt, stmt1;
+ private static ResultSet rs, rs1;
+ private static PreparedStatement pStmt = null;
+ private static CallableStatement callStmt = null;
+ static SQLWarning warnings;
+
+ //test all the supported SQL datatypes using updateXXX methods
+ private static String[] allSQLTypes =
+ {
+ "SMALLINT",
+ "INTEGER",
+ "BIGINT",
+ "DECIMAL(10,5)",
+ "REAL",
+ "DOUBLE",
+ "CHAR(60)",
+ "VARCHAR(60)",
+ "LONG VARCHAR",
+ "CHAR(2) FOR BIT DATA",
+ "VARCHAR(2) FOR BIT DATA",
+ "LONG VARCHAR FOR BIT DATA",
+ "CLOB(1k)",
+ "DATE",
+ "TIME",
+ "TIMESTAMP",
+ "BLOB(1k)",
+
+ };
+
+ //names for column names to test all the supported SQL datatypes using
updateXXX methods
+ private static String[] ColumnNames =
+ {
+ "SMALLINTCOL",
+ "INTEGERCOL",
+ "BIGINTCOL",
+ "DECIMALCOL",
+ "REALCOL",
+ "DOUBLECOL",
+ "CHARCOL",
+ "VARCHARCOL",
+ "LONGVARCHARCOL",
+ "CHARFORBITCOL",
+ "VARCHARFORBITCOL",
+ "LVARCHARFORBITCOL",
+ "CLOBCOL",
+ "DATECOL",
+ "TIMECOL",
+ "TIMESTAMPCOL",
+ "BLOBCOL",
+
+ };
+
+ //data to test all the supported SQL datatypes using updateXXX methods
+ private static String[][]SQLData =
+ {
+ {"11","22"}, // SMALLINT
+ {"111","1111"}, // INTEGER
+ {"22","222"}, // BIGINT
+ {"3.3","3.33"}, // DECIMAL(10,5)
+ {"4.4","4.44"}, // REAL,
+ {"5.5","5.55"}, // DOUBLE
+ {"'1992-01-06'","'1992'"}, // CHAR(60)
+ {"'1992-01-07'","'1992'"}, //VARCHAR(60)",
+ {"'1992-01-08'","'1992'"}, // LONG VARCHAR
+ {"X'10'","X'10aa'"}, // CHAR(2) FOR BIT DATA
+ {"X'10'","X'10bb'"}, // VARCHAR(2) FOR BIT DATA
+ {"X'10'","X'10cc'"}, //LONG VARCHAR FOR BIT DATA
+ {"'13'","'14'"}, //CLOB(1k)
+ {"'2000-01-01'","'2000-01-01'"}, // DATE
+ {"'15:30:20'","'15:30:20'"}, // TIME
+ {"'2000-01-01 15:30:20'","'2000-01-01 15:30:20'"}, //
TIMESTAMP
+ {"X'1020'","X'10203040'"} // BLOB
+ };
+
+ //used for printing useful messages about the test
+ private static String[] allUpdateXXXNames =
+ {
+ "updateShort",
+ "updateInt",
+ "updateLong",
+ "updateBigDecimal",
+ "updateFloat",
+ "updateDouble",
+ "updateString",
+ "updateAsciiStream",
+ "updateCharacterStream",
+ "updateByte",
+ "updateBytes",
+ "updateBinaryStream",
+ "updateClob",
+ "updateDate",
+ "updateTime",
+ "updateTimestamp",
+ "updateBlob",
+ "updateBoolean",
+ "updateNull",
+ "updateArray",
+ "updateRef"
+
+ };
+
+
+ //I have constructed following table based on if combination of
datatype and updateXXX method would work or not.
+ public static final String[][] updateXXXRulesTableForEmbedded = {
+
+ // Types. u u u u u u u u u u u u u u u u u u
u u u
+ // p p p p p p p p p p p p p p p p p
p p p p
+ // d d d d d d d d d d d d d d d d d
d d d d
+ // a a a a a a a a a a a a a a a a a a
a a a
+ // t t t t t t t t t t t t t t t t t t
t t t
+ // e e e e e e e e e e e e e e e e e e
e e e
+ // S I L B F D S A C B B B C D T T B B
N A R
+ // h n o i l o t s h y y i l a i i l
o u r e
+ // o t n g o u r c a t t n o t m m o
o l r f
+ // r g D a b i i r e e a b e e e b
l l a
+ // t e t l n i c s r s
e y
+ // c e g S t y t
a
+ // i t e S a
n
+ // m r r t m
+ // a e S r p
+ // l a t e
+ // m r a
+ // e m
+ // a
+ // m
+/* 0 SMALLINT */ { "PASS", "PASS", "PASS", "PASS", "PASS", "PASS",
"PASS", "ERROR", "ERROR", "PASS", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "PASS", "PASS", "ERROR", "ERROR" },
+/* 1 INTEGER */ { "PASS", "PASS", "PASS", "PASS", "PASS", "PASS",
"PASS", "ERROR", "ERROR", "PASS", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "PASS", "PASS", "ERROR", "ERROR" },
+/* 2 BIGINT */ { "PASS", "PASS", "PASS", "PASS", "PASS", "PASS",
"PASS", "ERROR", "ERROR", "PASS", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "PASS", "PASS", "ERROR", "ERROR" },
+/* 3 DECIMAL */ { "PASS", "PASS", "PASS", "PASS", "PASS", "PASS",
"PASS", "ERROR", "ERROR", "PASS", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "PASS", "PASS", "ERROR", "ERROR" },
+/* 4 REAL */ { "PASS", "PASS", "PASS", "PASS", "PASS", "PASS",
"PASS", "ERROR", "ERROR", "PASS", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "PASS", "PASS", "ERROR", "ERROR" },
+/* 5 DOUBLE */ { "PASS", "PASS", "PASS", "PASS", "PASS", "PASS",
"PASS", "ERROR", "ERROR", "PASS", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "PASS", "PASS", "ERROR", "ERROR" },
+/* 6 CHAR */ { "PASS", "PASS", "PASS", "PASS", "PASS", "PASS",
"PASS", "PASS", "PASS", "PASS", "PASS", "ERROR", "ERROR", "PASS", "PASS",
"PASS", "ERROR", "PASS", "PASS", "ERROR", "ERROR" },
+/* 7 VARCHAR */ { "PASS", "PASS", "PASS", "PASS", "PASS", "PASS",
"PASS", "PASS", "PASS", "PASS", "PASS", "ERROR", "ERROR", "PASS", "PASS",
"PASS", "ERROR", "PASS", "PASS", "ERROR", "ERROR" },
+/* 8 LONGVARCHAR */ { "PASS", "PASS", "PASS", "PASS", "PASS", "PASS",
"PASS", "PASS", "PASS", "PASS", "PASS", "ERROR", "ERROR", "PASS", "PASS",
"PASS", "ERROR", "PASS", "PASS", "ERROR", "ERROR" },
+/* 9 CHAR FOR BIT */ { "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "ERROR", "ERROR", "ERROR", "PASS", "PASS", "ERROR", "ERROR",
"ERROR", "ERROR", "ERROR", "ERROR", "PASS", "ERROR", "ERROR" },
+/* 10 VARCH. BIT */ { "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "ERROR", "ERROR", "ERROR", "PASS", "PASS", "ERROR", "ERROR",
"ERROR", "ERROR", "ERROR", "ERROR", "PASS", "ERROR", "ERROR" },
+/* 11 LONGVAR. BIT */ { "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "ERROR", "ERROR", "ERROR", "PASS", "PASS", "ERROR", "ERROR",
"ERROR", "ERROR", "ERROR", "ERROR", "PASS", "ERROR", "ERROR" },
+/* 12 CLOB */ { "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "PASS", "PASS", "PASS", "ERROR", "ERROR", "ERROR", "PASS", "ERROR",
"ERROR", "ERROR", "ERROR", "ERROR", "PASS", "ERROR", "ERROR" },
+/* 13 DATE */ { "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "PASS", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR", "PASS",
"ERROR", "PASS", "ERROR", "ERROR", "PASS", "ERROR", "ERROR" },
+/* 14 TIME */ { "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "PASS", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"PASS", "PASS", "ERROR", "ERROR", "PASS", "ERROR", "ERROR" },
+/* 15 TIMESTAMP */ { "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "PASS", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR", "PASS",
"PASS", "PASS", "ERROR", "ERROR", "PASS", "ERROR", "ERROR" },
+/* 16 BLOB */ { "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "ERROR", "ERROR", "ERROR", "PASS", "PASS", "ERROR", "ERROR",
"ERROR", "ERROR", "PASS", "ERROR", "PASS", "ERROR", "ERROR" },
+
+ };
+
+ //I have constructed following table for network server based on if
combination of datatype and updateXXX method would work or not.
+ public static final String[][] updateXXXRulesTableForNetworkServer = {
+
+ // Types. u u u u u u u u u u u u u u u u u u
u u u
+ // p p p p p p p p p p p p p p p p p
p p p p
+ // d d d d d d d d d d d d d d d d d
d d d d
+ // a a a a a a a a a a a a a a a a a a
a a a
+ // t t t t t t t t t t t t t t t t t t
t t t
+ // e e e e e e e e e e e e e e e e e e
e e e
+ // S I L B F D S A C B B B C D T T B B
N A R
+ // h n o i l o t s h y y i l a i i l
o u r e
+ // o t n g o u r c a t t n o t m m o
o l r f
+ // r g D a b i i r e e a b e e e b
l l a
+ // t e t l n i c s r s
e y
+ // c e g S t y t
a
+ // i t e S a
n
+ // m r r t m
+ // a e S r p
+ // l a t e
+ // m r a
+ // e m
+ // a
+ // m
+/* 0 SMALLINT */ { "PASS", "PASS", "PASS", "PASS", "PASS", "PASS",
"ERROR", "ERROR", "ERROR", "PASS", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "PASS", "PASS", "ERROR", "ERROR" },
+/* 1 INTEGER */ { "PASS", "PASS", "PASS", "PASS", "PASS", "PASS",
"ERROR", "ERROR", "ERROR", "PASS", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "PASS", "PASS", "ERROR", "ERROR" },
+/* 2 BIGINT */ { "PASS", "PASS", "PASS", "PASS", "PASS", "PASS",
"ERROR", "ERROR", "ERROR", "PASS", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "PASS", "PASS", "ERROR", "ERROR" },
+/* 3 DECIMAL */ { "PASS", "PASS", "PASS", "PASS", "PASS", "PASS",
"ERROR", "ERROR", "ERROR", "PASS", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "PASS", "PASS", "ERROR", "ERROR" },
+/* 4 REAL */ { "PASS", "PASS", "PASS", "PASS", "PASS", "PASS",
"PASS", "ERROR", "ERROR", "PASS", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "PASS", "PASS", "ERROR", "ERROR" },
+/* 5 DOUBLE */ { "PASS", "PASS", "PASS", "PASS", "PASS", "PASS",
"PASS", "ERROR", "ERROR", "PASS", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "PASS", "PASS", "ERROR", "ERROR" },
+/* 6 CHAR */ { "PASS", "PASS", "PASS", "PASS", "PASS", "PASS",
"PASS", "PASS", "PASS", "PASS", "ERROR", "ERROR", "ERROR", "PASS", "PASS",
"PASS", "ERROR", "PASS", "PASS", "ERROR", "ERROR" },
+/* 7 VARCHAR */ { "PASS", "PASS", "PASS", "PASS", "PASS", "PASS",
"PASS", "PASS", "PASS", "PASS", "ERROR", "ERROR", "ERROR", "PASS", "PASS",
"PASS", "ERROR", "PASS", "PASS", "ERROR", "ERROR" },
+/* 8 LONGVARCHAR */ { "PASS", "PASS", "PASS", "PASS", "PASS", "PASS",
"PASS", "PASS", "PASS", "PASS", "ERROR", "ERROR", "ERROR", "PASS", "PASS",
"PASS", "ERROR", "PASS", "PASS", "ERROR", "ERROR" },
+/* 9 CHAR FOR BIT */ { "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "ERROR", "ERROR", "ERROR", "PASS", "PASS", "ERROR", "ERROR",
"ERROR", "ERROR", "ERROR", "ERROR", "PASS", "ERROR", "ERROR" },
+/* 10 VARCH. BIT */ { "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "ERROR", "ERROR", "ERROR", "PASS", "PASS", "ERROR", "ERROR",
"ERROR", "ERROR", "ERROR", "ERROR", "PASS", "ERROR", "ERROR" },
+/* 11 LONGVAR. BIT */ { "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "ERROR", "ERROR", "ERROR", "PASS", "PASS", "ERROR", "ERROR",
"ERROR", "ERROR", "ERROR", "ERROR", "PASS", "ERROR", "ERROR" },
+/* 12 CLOB */ { "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "PASS", "PASS", "PASS", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "ERROR", "ERROR", "PASS", "ERROR", "ERROR" },
+/* 13 DATE */ { "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "PASS", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR", "PASS",
"ERROR", "PASS", "ERROR", "ERROR", "PASS", "ERROR", "ERROR" },
+/* 14 TIME */ { "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "PASS", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"PASS", "PASS", "ERROR", "ERROR", "PASS", "ERROR", "ERROR" },
+/* 15 TIMESTAMP */ { "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "PASS", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR", "ERROR", "PASS",
"ERROR", "PASS", "ERROR", "ERROR", "PASS", "ERROR", "ERROR" },
+/* 16 BLOB */ { "ERROR", "ERROR", "ERROR", "ERROR", "ERROR",
"ERROR", "ERROR", "ERROR", "ERROR", "ERROR", "PASS", "PASS", "ERROR", "ERROR",
"ERROR", "ERROR", "ERROR", "ERROR", "PASS", "ERROR", "ERROR" },
+
+ };
+
+ public static void main(String[] args) {
+ System.out.println("Start testing delete and update using
JDBC2.0 updateable resultset apis");
+
+ try {
+ // use the ij utility to read the property file and
+ // make the initial connection.
+ ij.getPropertyArg(args);
+ conn = ij.startJBMS();
+
+ setup(true);
+
+ System.out.println("Negative Testl - request for scroll
insensitive updatable resultset will give a read only scroll insensitive
resultset");
+ conn.clearWarnings();
+ stmt =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
+ warnings = conn.getWarnings();
+ while (warnings != null)
+ {
+ JDBCDisplayUtil.ShowWarnings(System.out,
warnings);
+ warnings = warnings.getNextWarning();
+ }
+ conn.clearWarnings();
+ System.out.println("requested TYPE_SCROLL_INSENSITIVE,
CONCUR_UPDATABLE but that is not supported");
+ System.out.println("Make sure that we got
TYPE_SCROLL_INSENSITIVE? " + (stmt.getResultSetType() ==
ResultSet.TYPE_SCROLL_INSENSITIVE));
+ System.out.println("Make sure that we got
CONCUR_READ_ONLY? " + (stmt.getResultSetConcurrency() ==
ResultSet.CONCUR_READ_ONLY));
+ dbmt = conn.getMetaData();
+
System.out.println("ownDeletesAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE)? "
+ dbmt.ownDeletesAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE));
+
System.out.println("othersDeletesAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE)?
" + dbmt.othersDeletesAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE));
+
System.out.println("deletesAreDetected(ResultSet.TYPE_SCROLL_INSENSITIVE)? " +
dbmt.deletesAreDetected(ResultSet.TYPE_SCROLL_INSENSITIVE));
+ System.out.println("JDBC 2.0 updatable resultset api
will fail on this resultset because this is not an updatable resultset");
+ rs = stmt.executeQuery("SELECT * FROM t1 FOR UPDATE");
+ rs.next();
+ try {
+ rs.deleteRow();
+ System.out.println("FAIL!!! deleteRow should
have failed because Derby does not yet support scroll insensitive updatable
resultsets");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ try {
+ rs.updateRow();
+ System.out.println("FAIL!!! updateRow should
have failed because Derby does not yet support scroll insensitive updatable
resultsets");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ rs.next();
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ System.out.println("Negative Test2 - request for scroll
sensitive updatable resultset will give a read only scroll insensitive
resultset");
+ stmt =
conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
+ while (warnings != null)
+ {
+ System.out.println("warnings on connection = "
+ warnings);
+ warnings = warnings.getNextWarning();
+ }
+ conn.clearWarnings();
+ System.out.println("requested TYPE_SCROLL_SENSITIVE, CONCUR_UPDATABLE
but that is not supported");
+ System.out.println("Jira issue Derby-154 : When client
connects to Network Server using JCC, it incorrectly shows support for scroll
sensitive updatable resultsets");
+ System.out.println("Make sure that we got TYPE_SCROLL_INSENSITIVE? " +
(stmt.getResultSetType() == ResultSet.TYPE_SCROLL_INSENSITIVE));
+ System.out.println("Make sure that we got CONCUR_READ_ONLY? " +
(stmt.getResultSetConcurrency() == ResultSet.CONCUR_READ_ONLY));
+ System.out.println("JDBC 2.0 updatable resultset api
will fail on this resultset because this is not an updatable resultset");
+ rs = stmt.executeQuery("SELECT * FROM t1 FOR UPDATE");
+ rs.next();
+ try {
+ rs.deleteRow();
+ System.out.println("FAIL!!! deleteRow should
have failed because Derby does not yet support scroll sensitive updatable
resultsets");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ try {
+ rs.updateRow();
+ System.out.println("FAIL!!! updateRow should
have failed because Derby does not yet support scroll sensitive updatable
resultsets");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ rs.next();
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ System.out.println("Negative Test3 - request a read
only resultset and attempt deleteRow and updateRow on it");
+ stmt = conn.createStatement();//the default is a read
only forward only resultset
+ rs = stmt.executeQuery("select * from t1");
+ System.out.println("Make sure that we got
CONCUR_READ_ONLY? " + (rs.getConcurrency() == ResultSet.CONCUR_READ_ONLY));
+ rs.next();
+ System.out.println("Now attempting to send a deleteRow on a read only
resultset.");
+ try {
+ rs.deleteRow();
+ System.out.println("FAIL!!! deleteRow should
have failed because this is a read only resultset");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("Now attempting to send an updateRow on a read only
resultset.");
+ try {
+ rs.updateRow();
+ System.out.println("FAIL!!! updateRow should
have failed because this is a read only resultset");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ System.out.println("Negative Test4 - request a read
only resultset and send a sql with FOR UPDATE clause and attempt
deleteRow/updateRow on it");
+ stmt = conn.createStatement();//the default is a read
only forward only resultset
+ rs = stmt.executeQuery("select * from t1 FOR UPDATE");
+ System.out.println("Make sure that we got
CONCUR_READ_ONLY? " + (rs.getConcurrency() == ResultSet.CONCUR_READ_ONLY));
+ rs.next();
+ System.out.println("Now attempting to send a deleteRow on a read only
resultset with FOR UPDATE clause in the SELECT sql.");
+ try {
+ rs.deleteRow();
+ System.out.println("FAIL!!! deleteRow should
have failed because this is a read only resultset");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("Now attempting to send a updateRow
on a read only resultset with FOR UPDATE clause in the SELECT sql.");
+ try {
+ rs.updateRow();
+ System.out.println("FAIL!!! updateRow should
have failed because this is a read only resultset");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+
+ System.out.println("Negative Test5 - request updatable
resultset for sql with no FOR UPDATE clause");
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("select * from t1");//notice
that we forgot to give mandatory FOR UPDATE clause for updatable resultset
+ System.out.println("Make sure that we got
CONCUR_READ_ONLY? " + (rs.getConcurrency() == ResultSet.CONCUR_READ_ONLY));
+ System.out.println("Jira issue Derby-159 : Warnings
raised by Derby are not getting passed to the Client in Network Server Mode");
+ System.out.println("Will see the warnings in embedded
mode only");
+ warnings = rs.getWarnings();
+ while (warnings != null)
+ {
+ System.out.println("Expected warnings on
resultset = " + warnings);
+ warnings = warnings.getNextWarning();
+ }
+ rs.clearWarnings();
+ rs.next();
+ System.out.println("Now attempting to send a delete on a sql with no FOR
UPDATE clause.");
+ try {
+ rs.deleteRow();
+ System.out.println("FAIL!!! deleteRow should
have failed on sql with no FOR UPDATE clause");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("Now attempting to send a updateRow on a sql with no
FOR UPDATE clause.");
+ try {
+ rs.updateRow();
+ System.out.println("FAIL!!! updateRow should
have failed on sql with no FOR UPDATE clause");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ System.out.println("Negative Test6 - request updatable
resultset for sql with FOR READ ONLY clause");
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("select * from t1 FOR READ
ONLY");
+ System.out.println("Make sure that we got
CONCUR_READ_ONLY? " + (rs.getConcurrency() == ResultSet.CONCUR_READ_ONLY));
+ System.out.println("Jira issue Derby-159 : Warnings
raised by Derby are not getting passed to the Client in Network Server Mode");
+ System.out.println("Will see the warnings in embedded
mode only");
+ warnings = rs.getWarnings();
+ while (warnings != null)
+ {
+ System.out.println("Expected warnings on
resultset = " + warnings);
+ warnings = warnings.getNextWarning();
+ }
+ rs.clearWarnings();
+ rs.next();
+ System.out.println("Now attempting to send a delete on a sql with FOR
READ ONLY clause.");
+ try {
+ rs.deleteRow();
+ System.out.println("FAIL!!! deleteRow should
have failed on sql with FOR READ ONLY clause");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("Now attempting to send a updateRow
on a sql with FOR READ ONLY clause.");
+ try {
+ rs.updateRow();
+ System.out.println("FAIL!!! updateRow should
have failed on sql with FOR READ ONLY clause");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ System.out.println("Negative Test7 - attempt to
deleteRow & updateRow on updatable resultset when the resultset is not
positioned on a row");
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT * FROM t1 FOR UPDATE");
+ System.out.println("Make sure that we got
CONCUR_UPDATABLE? " + (rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE));
+ System.out.println("Now attempt a deleteRow without first doing next on
the resultset.");
+ try {
+ rs.deleteRow();
+ System.out.println("FAIL!!! deleteRow should
have failed because resultset is not on a row");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("Now attempt a updateRow without first doing next on
the resultset.");
+ System.out.println("In embedded mode, updateRow will
check if it is on a row or not even though no changes have been made to the row
using updateXXX");
+ System.out.println("In Network Server mode, if no
updateXXX were issued before updateRow, then updateRow is a no-op and doesn't
check if it is on a row or not");
+ try {
+ rs.updateRow();
+ if (TestUtil.isEmbeddedFramework())
+ System.out.println("FAIL!!! In embedded
mode, this updateRow should have failed because resultset is not on a row");
+ else
+ System.out.println("PASS!!! In Network
Server mode, this updateRow is a no-op because no updateXXX were issued before
the updateRow");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ while (rs.next());//read all the rows from the
resultset and position after the last row
+ System.out.println("ResultSet is positioned after the last row. attempt
to deleteRow at this point should fail!");
+ try {
+ rs.deleteRow();
+ System.out.println("FAIL!!! deleteRow should
have failed because resultset is after the last row");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("ResultSet is positioned after the
last row. attempt to updateRow at this point should fail!");
+ try {
+ rs.updateRow();
+ System.out.println("FAIL!!! updateRow should
have failed because resultset is after the last row");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ rs.close();
+
+ System.out.println("Negative Test8 - attempt deleteRow
& updateRow on updatable resultset after closing the resultset");
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT * FROM t1 FOR UPDATE");
+ System.out.println("Make sure that we got
CONCUR_UPDATABLE? " + (rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE));
+ rs.next();
+ rs.close();
+ try {
+ rs.deleteRow();
+ System.out.println("FAIL!!! deleteRow should
have failed because resultset is closed");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ try {
+ rs.updateRow();
+ System.out.println("FAIL!!! updateRow should
have failed because resultset is closed");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+
+ System.out.println("Negative Test9 - try updatable
resultset on system table");
+ try {
+ rs = stmt.executeQuery("SELECT * FROM
sys.systables FOR UPDATE");
+ System.out.println("FAIL!!! trying to open an
updatable resultset on a system table should have failed because system tables
can't be updated by a user");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+
+ System.out.println("Negative Test10 - try updatable
resultset on a view");
+ try {
+ rs = stmt.executeQuery("SELECT * FROM v1 FOR
UPDATE");
+ System.out.println("FAIL!!! trying to open an
updatable resultset on a view should have failed because Derby doesnot support
updates to views yet");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ stmt.executeUpdate("drop view v1");
+
+ System.out.println("Negative Test11 - attempt to open
updatable resultset when there is join in the select query should fail");
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ try {
+ rs = stmt.executeQuery("SELECT c1 FROM t1,t2
where t1.c1 = t2.c21 FOR UPDATE");
+ System.out.println("FAIL!!! trying to open an
updatable resultset should have failed because updatable resultset donot
support join in the select query");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+
+ System.out.println("Negative Test12 - With autocommit
on, attempt to drop a table when there is an open updatable resultset on it");
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT c1 FROM t1 FOR UPDATE");
+ rs.next();
+ rs.updateInt(1,123);
+ System.out.println("Opened an updatable resultset. Now
trying to drop that table through another Statement");
+ stmt1 = conn.createStatement();
+ try {
+ stmt1.executeUpdate("drop table t1");
+ System.out.println("FAIL!!! drop table should
have failed because the updatable resultset is still open");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("Since autocommit is on, the drop
table exception resulted in a runtime rollback causing updatable resultset
object to close");
+ try {
+ rs.updateRow();
+ System.out.println("FAIL!!! resultset should
have been closed at this point and updateRow should have failed");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ try {
+ rs.deleteRow();
+ System.out.println("FAIL!!! resultset should
have been closed at this point and deleteRow should have failed");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+
+ System.out.println("Negative Test13 - foreign key
constraint failure will cause deleteRow to fail");
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT * FROM tableWithPrimaryKey FOR UPDATE");
+ rs.next();
+ try {
+ rs.deleteRow();
+ System.out.println("FAIL!!! deleteRow should
have failed because it will cause foreign key constraint failure");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("Since autocommit is on, the
constraint exception resulted in a runtime rollback causing updatable resultset
object to close");
+ try {
+ rs.next();
+ if (TestUtil.isNetFramework())
+ System.out.println("Jira entry
Derby-160 : for Network Server because next should have failed");
+ System.out.println("FAIL!!! next should have
failed because foreign key constraint failure resulted in a runtime rollback");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+
+ System.out.println("Negative Test14 - foreign key
constraint failure will cause updateRow to fail");
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT c1, c2 FROM
tableWithPrimaryKey FOR UPDATE");
+ rs.next();
+ rs.updateInt(1,11);
+ rs.updateInt(2,22);
+ try {
+ rs.updateRow();
+ System.out.println("FAIL!!! updateRow should
have failed because it will cause foreign key constraint failure");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("Since autocommit is on, the
constraint exception resulted in a runtime rollback causing updatable resultset
object to close");
+ try {
+ rs.next();
+ if (TestUtil.isNetFramework())
+ System.out.println("Jira entry
Derby-160 : for Network Server because next should have failed");
+ System.out.println("FAIL!!! next should have
failed because foreign key constraint failure resulted in a runtime rollback");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+
+ System.out.println("Negative Test15 - Can't call
updateXXX methods on columns that do not correspond to a column in the table");
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT 1, 2 FROM t1 FOR
UPDATE");
+ rs.next();
+ try {
+ rs.updateInt(1,22);
+ System.out.println("FAIL!!! updateInt should
have failed because it is trying to update a column that does not correspond to
column in base table");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+
+ System.out.println("Negative Test16 - Call updateXXX
method on out of the range column");
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT c1, c2 FROM t1 FOR
UPDATE");
+ rs.next();
+ System.out.println("There are only 2 columns in the
select list and we are trying to send updateXXX on column position 3");
+ try {
+ rs.updateInt(3,22);
+ System.out.println("FAIL!!! updateInt should
have failed because there are only 2 columns in the select list");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+
+ System.out.println("Positive Test1a - request updatable
resultset for forward only type resultset");
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ warnings = conn.getWarnings();
+ while (warnings != null)
+ {
+ System.out.println("Unexpected warnings = " +
warnings);
+ warnings = warnings.getNextWarning();
+ }
+ System.out.println("requested TYPE_FORWARD_ONLY, CONCUR_UPDATABLE");
+ System.out.println("got TYPE_FORWARD_ONLY? " + (stmt.getResultSetType()
== ResultSet.TYPE_FORWARD_ONLY));
+ System.out.println("got CONCUR_UPDATABLE? " +
(stmt.getResultSetConcurrency() == ResultSet.CONCUR_UPDATABLE));
+ rs = stmt.executeQuery("SELECT * FROM t1 FOR UPDATE");
+ System.out.println("JDBC 2.0 updatable resultset apis
on this ResultSet object will pass because this is an updatable resultset");
+ rs.next();
+ System.out.println("column 1 on this row before deleteRow is " +
rs.getInt(1));
+ System.out.println("column 2 on this row before deleteRow is " +
rs.getString(2));
+ rs.deleteRow();
+ System.out.println("Since after deleteRow(), in embedded mode, ResultSet
is positioned before the next row, getXXX will fail");
+ System.out.println("In Network Server mode, the ResultSet stays on the
deleted row after deleteRow and hence no error for getXXX");
+ try {
+ System.out.println("column 1 on this deleted
row is " + rs.getInt(1));
+ }
+ catch (SQLException e) {
+ if (TestUtil.isEmbeddedFramework()) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected
exception " + e.getMessage());
+ } else
+ System.out.println("Got unexpected
exception " + e.getMessage());
+ }
+ System.out.println("calling deleteRow again w/o first positioning the
ResultSet on the next row will fail");
+ try {
+ rs.deleteRow();
+ System.out.println("FAIL!!! deleteRow should
have failed because ResultSet is not positioned on a row");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("Position the ResultSet with next()");
+ rs.next();
+ System.out.println("Should be able to deletRow() on the current row
now");
+ rs.deleteRow();
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ if (TestUtil.isEmbeddedFramework()) {
+ System.out.println("Positive Test1b - request updatable
resultset for forward only type resultset");
+ reloadData();
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ warnings = conn.getWarnings();
+ while (warnings != null)
+ {
+ System.out.println("Unexpected warnings = " +
warnings);
+ warnings = warnings.getNextWarning();
+ }
+ rs = stmt.executeQuery("SELECT * FROM t1 FOR UPDATE");
+ rs.next();
+ System.out.println("column 1 on this row before
updateInt is " + rs.getInt(1));
+ rs.updateInt(1,234);
+ System.out.println("column 1 on this row after
updateInt is " + rs.getInt(1));
+ System.out.println("column 2 on this row before
updateString is " + rs.getString(2));
+ System.out.println("now updateRow on the row");
+ rs.updateRow();
+ System.out.println("Since after updateRow(), in
embedded mode, ResultSet is positioned before the next row, getXXX will fail");
+ System.out.println("In Network Server mode, the ResultSet stays on the
updated row after updateRow and hence no error for getXXX");
+ try {
+ System.out.println("column 1 on this updateRow
row is " + rs.getInt(1));
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("calling updateRow again w/o first
positioning the ResultSet on the next row will fail");
+ try {
+ rs.updateRow();
+ System.out.println("FAIL!!! updateRow should
have failed because ResultSet is not positioned on a row");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("Position the ResultSet with
next()");
+ rs.next();
+ System.out.println("Should be able to updateRow() on
the current row now");
+ rs.updateString(2,"234");
+ rs.updateRow();
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ System.out.println("Positive Test2 - even if no columns
from table specified in the column list, we should be able to get updatable
resultset");
+ reloadData();
+ System.out.println("total number of rows in T1 ");
+ dumpRS(stmt.executeQuery("select count(*) from t1"));
+ rs = stmt.executeQuery("SELECT 1, 2 FROM t1 FOR UPDATE");
+ rs.next();
+ System.out.println("column 1 on this row is " + rs.getInt(1));
+ rs.deleteRow();
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+ System.out.println("total number of rows in T1 after one deleteRow is ");
+ dumpRS(stmt.executeQuery("select count(*) from t1"));
+
+ System.out.println("Positive Test3a - use prepared
statement with concur updatable status to test deleteRow");
+ reloadData();
+ pStmt = conn.prepareStatement("select * from t1 where
c1>? for update", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ System.out.println("requested TYPE_FORWARD_ONLY, CONCUR_UPDATABLE");
+ System.out.println("got TYPE_FORWARD_ONLY? " +
(pStmt.getResultSetType() == ResultSet.TYPE_FORWARD_ONLY));
+ System.out.println("got CONCUR_UPDATABLE? " +
(pStmt.getResultSetConcurrency() == ResultSet.CONCUR_UPDATABLE));
+ pStmt.setInt(1,0);
+ rs = pStmt.executeQuery();
+ rs.next();
+ System.out.println("column 1 on this row is " + rs.getInt(1));
+ rs.deleteRow();
+ System.out.println("Since after deleteRow(), ResultSet is positioned
before the next row, getXXX will fail");
+ try {
+ System.out.println("column 1 on this deleted
row is " + rs.getInt(1));
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("calling deleteRow again w/o first positioning the
ResultSet on the next row will fail");
+ try {
+ rs.deleteRow();
+ System.out.println("FAIL!!! deleteRow should
have failed because it can't be called more than once on the same row");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("Position the ResultSet with next()");
+ rs.next();
+ System.out.println("Should be able to deletRow() on the current row
now");
+ rs.deleteRow();
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ System.out.println("Positive Test3b - use prepared
statement with concur updatable status to test updateXXX");
+ reloadData();
+ pStmt = conn.prepareStatement("select * from t1 where
c1>? for update", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ System.out.println("requested TYPE_FORWARD_ONLY,
CONCUR_UPDATABLE");
+ System.out.println("got TYPE_FORWARD_ONLY? " +
(pStmt.getResultSetType() == ResultSet.TYPE_FORWARD_ONLY));
+ System.out.println("got CONCUR_UPDATABLE? " +
(pStmt.getResultSetConcurrency() == ResultSet.CONCUR_UPDATABLE));
+ pStmt.setInt(1,0);
+ rs = pStmt.executeQuery();
+ rs.next();
+ System.out.println("column 1 on this row is " +
rs.getInt(1));
+ rs.updateInt(1,5);
+ System.out.println("column 1 on this row after
updateInt is " + rs.getInt(1));
+ rs.updateRow();
+ System.out.println("Since after updateRow(), ResultSet
is positioned before the next row, getXXX will fail");
+ try {
+ System.out.println("column 1 on this updated
row is " + rs.getInt(1));
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("calling updateRow/updateXXX again
w/o first positioning the ResultSet on the next row will fail");
+ try {
+ rs.updateInt(1,0);
+ System.out.println("FAIL!!! updateXXX should
have failed because resultset is not positioned on a row");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ try {
+ rs.updateRow();
+ System.out.println("FAIL!!! updateRow should
have failed because resultset is not positioned on a row");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ try {
+ rs.cancelRowUpdates();
+ System.out.println("FAIL!!! cancelRowUpdates
should have failed because resultset is not positioned on a row");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("Position the ResultSet with
next()");
+ rs.next();
+ System.out.println("Should be able to
cancelRowUpdates() on the current row now");
+ rs.cancelRowUpdates();
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ System.out.println("Positive Test4 - use callable
statement with concur updatable status");
+ reloadData();
+ callStmt = conn.prepareCall("select * from t1 for
update", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = callStmt.executeQuery();
+ System.out.println("requested TYPE_FORWARD_ONLY, CONCUR_UPDATABLE");
+ System.out.println("got TYPE_FORWARD_ONLY? " +
(callStmt.getResultSetType() == ResultSet.TYPE_FORWARD_ONLY));
+ System.out.println("got CONCUR_UPDATABLE? " +
(callStmt.getResultSetConcurrency() == ResultSet.CONCUR_UPDATABLE));
+ rs.next();
+ System.out.println("column 1 on this row is " + rs.getInt(1));
+ rs.deleteRow();
+ System.out.println("Since after deleteRow(), ResultSet is positioned
before the next row, getXXX will fail");
+ try {
+ System.out.println("column 1 on this deleted
row is " + rs.getInt(1));
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("calling deleteRow again w/o first positioning the
ResultSet on the next row will fail");
+ try {
+ rs.deleteRow();
+ System.out.println("FAIL!!! deleteRow should
have failed because it can't be called more than once on the same row");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("Position the ResultSet with next()");
+ rs.next();
+ System.out.println("Should be able to deletRow() on the current row
now");
+ rs.deleteRow();
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ System.out.println("Positive Test5 - donot have to
select primary key to get an updatable resultset");
+ reloadData();
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT c32 FROM t3 FOR UPDATE");
+ rs.next();
+ System.out.println("column 1 on this row is " + rs.getInt(1));
+ System.out.println("now try to delete row when primary key is not
selected for that row");
+ rs.deleteRow();
+ rs.next();
+ rs.updateLong(1,123);
+ rs.updateRow();
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ System.out.println("Positive Test6a - For Forward Only
resultsets, DatabaseMetaData will return false for ownDeletesAreVisible and
deletesAreDetected");
+ System.out.println("This is because, after deleteRow,
we position the ResultSet before the next row. We don't make a hole for the
deleted row and then stay on that deleted hole");
+ dbmt = conn.getMetaData();
+ System.out.println("ownDeletesAreVisible(ResultSet.TYPE_FORWARD_ONLY)? "
+ dbmt.ownDeletesAreVisible(ResultSet.TYPE_FORWARD_ONLY));
+
System.out.println("othersDeletesAreVisible(ResultSet.TYPE_FORWARD_ONLY)? " +
dbmt.othersDeletesAreVisible(ResultSet.TYPE_FORWARD_ONLY));
+ System.out.println("deletesAreDetected(ResultSet.TYPE_FORWARD_ONLY)? " +
dbmt.deletesAreDetected(ResultSet.TYPE_FORWARD_ONLY));
+ reloadData();
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT 1, 2 FROM t1 FOR UPDATE of c1");
+ rs.next();
+ System.out.println("The JDBC program should look at rowDeleted only if
deletesAreDetected returns true");
+ System.out.println("Since Derby returns false for detlesAreDetected for
FORWARD_ONLY updatable resultset,the program should not rely on rs.rowDeleted()
for FORWARD_ONLY updatable resultsets");
+ System.out.println("Have this call to rs.rowDeleted() just to make sure
the method does always return false? " + rs.rowDeleted());
+ rs.deleteRow();
+ System.out.println("Have this call to rs.rowDeleted() just to make sure
the method does always return false? " + rs.rowDeleted());
+ rs.close();
+
+ System.out.println("Positive Test6b - For Forward Only
resultsets, DatabaseMetaData will return false for ownUpdatesAreVisible and
updatesAreDetected");
+ System.out.println("This is because, after updateRow,
we position the ResultSet before the next row");
+ dbmt = conn.getMetaData();
+
System.out.println("ownUpdatesAreVisible(ResultSet.TYPE_FORWARD_ONLY)? " +
dbmt.ownUpdatesAreVisible(ResultSet.TYPE_FORWARD_ONLY));
+
System.out.println("othersUpdatesAreVisible(ResultSet.TYPE_FORWARD_ONLY)? " +
dbmt.othersUpdatesAreVisible(ResultSet.TYPE_FORWARD_ONLY));
+
System.out.println("updatesAreDetected(ResultSet.TYPE_FORWARD_ONLY)? " +
dbmt.updatesAreDetected(ResultSet.TYPE_FORWARD_ONLY));
+ reloadData();
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT * FROM t1 FOR UPDATE of
c1");
+ rs.next();
+ System.out.println("The JDBC program should look at
rowUpdated only if updatesAreDetected returns true");
+ System.out.println("Since Derby returns false for
updatesAreDetected for FORWARD_ONLY updatable resultset,the program should not
rely on rs.rowUpdated() for FORWARD_ONLY updatable resultsets");
+ System.out.println("Have this call to rs.rowUpdated()
just to make sure the method does always return false? " + rs.rowUpdated());
+ rs.updateLong(1,123);
+ rs.updateRow();
+ System.out.println("Have this call to rs.rowUpdated()
just to make sure the method does always return false? " + rs.rowUpdated());
+ rs.close();
+
+ System.out.println("Positive Test7a - delete using
updatable resultset api from a temporary table");
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ stmt.executeUpdate("DECLARE GLOBAL TEMPORARY TABLE
SESSION.t2(c21 int, c22 int) on commit preserve rows not logged");
+ stmt.executeUpdate("insert into SESSION.t2 values(21,
1)");
+ stmt.executeUpdate("insert into SESSION.t2 values(22,
1)");
+ System.out.println("following rows in temp table before
deleteRow");
+ dumpRS(stmt.executeQuery("select * from SESSION.t2"));
+ rs = stmt.executeQuery("select c21 from session.t2 for
update");
+ rs.next();
+ rs.deleteRow();
+ rs.next();
+ rs.deleteRow();
+ System.out.println("As expected, no rows in temp table
after deleteRow");
+ dumpRS(stmt.executeQuery("select * from SESSION.t2"));
+ rs.close();
+ stmt.executeUpdate("DROP TABLE SESSION.t2");
+
+ System.out.println("Positive Test7b - update using
updatable resultset api from a temporary table");
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ stmt.executeUpdate("DECLARE GLOBAL TEMPORARY TABLE
SESSION.t3(c31 int, c32 int) on commit preserve rows not logged");
+ stmt.executeUpdate("insert into SESSION.t3 values(21,
1)");
+ stmt.executeUpdate("insert into SESSION.t3 values(22,
1)");
+ System.out.println("following rows in temp table before
deleteRow");
+ dumpRS(stmt.executeQuery("select * from SESSION.t3"));
+ rs = stmt.executeQuery("select c31 from session.t3 for
update");
+ rs.next();
+ rs.updateLong(1,123);
+ rs.updateRow();
+ rs.next();
+ rs.updateLong(1,123);
+ rs.updateRow();
+ System.out.println("As expected, updated rows in temp
table after updateRow");
+ dumpRS(stmt.executeQuery("select * from SESSION.t3"));
+ rs.close();
+ stmt.executeUpdate("DROP TABLE SESSION.t3");
+
+ System.out.println("Positive Test8a - change the name
of the resultset and see if deleteRow still works");
+ reloadData();
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ System.out.println("change the cursor name(case sensitive name) with
setCursorName and then try to deleteRow");
+ stmt.setCursorName("CURSORNOUPDATe");//notice this name
is case sensitive
+ rs = stmt.executeQuery("SELECT 1, 2 FROM t1 FOR UPDATE of c1");
+ rs.next();
+ rs.deleteRow();
+ System.out.println("change the cursor name one more time with
setCursorName and then try to deleteRow");
+ stmt.setCursorName("CURSORNOUPDATE1");
+ rs.next();
+ rs.deleteRow();
+ rs.close();
+
+ System.out.println("Positive Test8b - change the name
of the resultset and see if updateRow still works");
+ reloadData();
+ System.out.println("change the cursor name one more
time with setCursorName and then try to updateRow");
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ System.out.println("change the cursor name(case
sensitive name) with setCursorName and then try to updateRow");
+ stmt.setCursorName("CURSORNOUPDATe");//notice this name
is case sensitive
+ rs = stmt.executeQuery("SELECT * FROM t1 FOR UPDATE of
c1");
+ rs.next();
+ rs.updateLong(1,123);
+ stmt.setCursorName("CURSORNOUPDATE1");
+ rs.updateRow();
+ rs.close();
+
+ System.out.println("Positive Test9a - using correlation
name for the table in the select sql is not a problem");
+ reloadData();
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT 1, 2 FROM t1 abcde FOR UPDATE of c1");
+ rs.next();
+ System.out.println("column 1 on this row is " + rs.getInt(1));
+ System.out.println("now try to deleteRow");
+ rs.deleteRow();
+ rs.close();
+
+ System.out.println("Positive Test9b - using correlation
name for updatable column name is not allowed");
+ reloadData();
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ System.out.println("Table t1 has following rows");
+ dumpRS(stmt.executeQuery("select * from t1"));
+ try {
+ System.out.println("attempt to get an updatable
resultset using correlation name for an updatable column");
+ System.out.println("The sql is SELECT c1 as
col1, c2 as col2 FROM t1 abcde FOR UPDATE of c1");
+ rs = stmt.executeQuery("SELECT c1 as col1, c2
as col2 FROM t1 abcde FOR UPDATE of c1");
+ System.out.println("FAIL!!! executeQuery should
have failed");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("attempt to get an updatable
resultset using correlation name for an readonly column. It should work");
+ System.out.println("The sql is SELECT c1, c2 as col2
FROM t1 abcde FOR UPDATE of c1");
+ rs = stmt.executeQuery("SELECT c1, c2 as col2 FROM t1
abcde FOR UPDATE of c1");
+ rs.next();
+ rs.updateInt(1,11);
+ rs.updateRow();
+ rs.close();
+ System.out.println("Table t1 after updateRow has
following rows");
+ dumpRS(stmt.executeQuery("select * from t1"));
+
+ System.out.println("Positive Test9c - try to updateXXX
on a readonly column. Should get error");
+ reloadData();
+ rs = stmt.executeQuery("SELECT c1, c2 FROM t1 abcde FOR
UPDATE of c1");
+ rs.next();
+ try {
+ rs.updateString(2,"bbbb");
+ System.out.println("FAIL!!! updateString on
readonly column should have failed");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("attempt to get an updatable
resultset using correlation name for an readonly column. It should work");
+ System.out.println("The sql is SELECT c1, c2 as col2
FROM t1 abcde FOR UPDATE of c1");
+ rs = stmt.executeQuery("SELECT c1, c2 as col2 FROM t1
abcde FOR UPDATE of c1");
+ rs.next();
+ rs.updateInt(1,11);
+ rs.updateRow();
+ rs.close();
+ System.out.println("Table t1 after updateRow has
following rows");
+ dumpRS(stmt.executeQuery("select * from t1"));
+
+ System.out.println("Positive Test9c - try to updateXXX
on a readonly column. Should get error");
+ reloadData();
+ rs = stmt.executeQuery("SELECT c1, c2 FROM t1 abcde FOR
UPDATE of c1");
+ rs.next();
+ try {
+ rs.updateString(2,"bbbb");
+ System.out.println("FAIL!!! updateString on
readonly column should have failed");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ rs.close();
+ System.out.println("Table t1 has following rows");
+ dumpRS(stmt.executeQuery("select * from t1"));
+
+ System.out.println("Positive Test9d - try to updateXXX
on a readonly column with correlation name. Should get error");
+ reloadData();
+ rs = stmt.executeQuery("SELECT c1, c2 as col2 FROM t1
abcde FOR UPDATE of c1");
+ rs.next();
+ try {
+ rs.updateString(2,"bbbb");
+ System.out.println("FAIL!!! updateString on
readonly column should have failed");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ rs.close();
+ System.out.println("Table t1 has following rows");
+ dumpRS(stmt.executeQuery("select * from t1"));
+
+ System.out.println("Positive Test10 - 2 updatable
resultsets going against the same table, will they conflict?");
+ conn.setAutoCommit(false);
+ reloadData();
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ stmt1 =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT 1, 2 FROM t1 FOR UPDATE");
+ rs.next();
+ rs1 = stmt1.executeQuery("SELECT 1, 2 FROM t1 FOR
UPDATE");
+ rs1.next();
+ System.out.println("delete using first resultset");
+ rs.deleteRow();
+ try {
+ System.out.println("attempt to send deleteRow
on the same row through a different resultset should throw an exception");
+ rs1.deleteRow();
+ System.out.println("FAIL!!! delete using second
resultset succedded? ");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("Move to next row in the 2nd
resultset and then delete using the second resultset");
+ rs1.next();
+ rs1.deleteRow();
+ rs.close();
+ rs1.close();
+ conn.setAutoCommit(true);
+
+ System.out.println("Positive Test11 - setting the fetch
size to > 1 will be ignored by updatable resultset. Same as updatable cursors");
+ reloadData();
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ stmt.executeUpdate("call
SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(1)");
+ stmt.setFetchSize(200);
+ rs = stmt.executeQuery("SELECT 1, 2 FROM t1 FOR UPDATE of c1");
+ System.out.println("Notice the Fetch Size in run time
statistics output.");
+ showScanStatistics(rs, conn);
+ System.out.println("statement's fetch size is " +
stmt.getFetchSize());
+ rs.close();
+ stmt.executeUpdate("call
SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(0)");
+
+ System.out.println("Positive Test12a - make sure delete
trigger gets fired when deleteRow is issued");
+ reloadData();
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ System.out.println("Verify that before delete trigger
got fired, row count is 0 in deleteTriggerInsertIntoThisTable");
+ dumpRS(stmt.executeQuery("select count(*) from
deleteTriggerInsertIntoThisTable"));
+ rs = stmt.executeQuery("SELECT * FROM
table0WithTriggers FOR UPDATE");
+ rs.next();
+ System.out.println("column 1 on this row is " +
rs.getInt(1));
+ System.out.println("now try to delete row and make sure
that trigger got fired");
+ rs.deleteRow();
+ rs.close();
+ System.out.println("Verify that delete trigger got
fired by verifying the row count to be 1 in deleteTriggerInsertIntoThisTable");
+ dumpRS(stmt.executeQuery("select count(*) from
deleteTriggerInsertIntoThisTable"));
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ System.out.println("Positive Test12b - make sure update
trigger gets fired when updateRow is issued");
+ reloadData();
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ System.out.println("Verify that before update trigger
got fired, row count is 0 in updateTriggerInsertIntoThisTable");
+ dumpRS(stmt.executeQuery("select count(*) from
updateTriggerInsertIntoThisTable"));
+ rs = stmt.executeQuery("SELECT * FROM
table0WithTriggers FOR UPDATE");
+ rs.next();
+ System.out.println("column 1 on this row is " +
rs.getInt(1));
+ System.out.println("now try to update row and make sure
that trigger got fired");
+ rs.updateLong(1,123);
+ rs.updateRow();
+ rs.close();
+ System.out.println("Verify that update trigger got
fired by verifying the row count to be 1 in updateTriggerInsertIntoThisTable");
+ dumpRS(stmt.executeQuery("select count(*) from
updateTriggerInsertIntoThisTable"));
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ System.out.println("Positive Test13a - Another test
case for delete trigger");
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT * FROM
table1WithTriggers FOR UPDATE");
+ rs.next();
+ System.out.println("column 1 on this row is " +
rs.getInt(1));
+ System.out.println("this delete row will fire the
delete trigger which will delete all the rows from the table and from the
resultset");
+ rs.deleteRow();
+ rs.next();
+ try {
+ rs.deleteRow();
+ System.out.println("FAIL!!! there should have
be no more rows in the resultset at this point because delete trigger deleted
all the rows");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ rs.close();
+ System.out.println("Verify that delete trigger got
fired by verifying the row count to be 0 in table1WithTriggers");
+ dumpRS(stmt.executeQuery("select count(*) from
table1WithTriggers"));
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ System.out.println("Positive Test13b - Another test
case for update trigger");
+ System.out.println("Look at the current contents of
table2WithTriggers");
+ dumpRS(stmt.executeQuery("select * from
table2WithTriggers"));
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT * FROM
table2WithTriggers where c1>1 FOR UPDATE");
+ rs.next();
+ System.out.println("column 1 on this row is " +
rs.getInt(1));
+ System.out.println("this update row will fire the
update trigger which will update all the rows in the table to have c1=1 and
hence no more rows will qualify for the resultset");
+ rs.updateLong(1,123);
+ rs.updateRow();
+ rs.next();
+ try {
+ rs.updateRow();
+ System.out.println("FAIL!!! there should have
be no more rows in the resultset at this point because update trigger made all
the rows not qualify for the resultset");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ rs.close();
+ System.out.println("Verify that update trigger got
fired by verifying that all column c1s have value 1 in table2WithTriggers");
+ dumpRS(stmt.executeQuery("select * from
table2WithTriggers"));
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ System.out.println("Positive Test14a - make sure self
referential delete cascade works when deleteRow is issued");
+ dumpRS(stmt.executeQuery("select * from
selfReferencingT1"));
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT * FROM selfReferencingT1
FOR UPDATE");
+ rs.next();
+ System.out.println("column 1 on this row is " +
rs.getString(1));
+ System.out.println("this delete row will cause the
delete cascade constraint to delete all the rows from the table and from the
resultset");
+ rs.deleteRow();
+ rs.next();
+ try {
+ rs.deleteRow();
+ System.out.println("FAIL!!! there should have
be no more rows in the resultset at this point because delete cascade deleted
all the rows");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ rs.close();
+ System.out.println("Verify that delete trigger got
fired by verifying the row count to be 0 in selfReferencingT1");
+ dumpRS(stmt.executeQuery("select count(*) from
selfReferencingT1"));
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ System.out.println("Positive Test14b - make sure self
referential update restrict works when updateRow is issued");
+ dumpRS(stmt.executeQuery("select * from
selfReferencingT2"));
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT * FROM selfReferencingT2
FOR UPDATE");
+ rs.next();
+ System.out.println("column 1 on this row is " +
rs.getString(1));
+ System.out.println("update row should fail because
cascade constraint is update restrict");
+ rs.updateString(1,"e2");
+ try {
+ rs.updateRow();
+ System.out.println("FAIL!!! this update should
have caused violation of foreign key constraint");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ System.out.println("Positive Test15 - With autocommit
off, attempt to drop a table when there is an open updatable resultset on it");
+ reloadData();
+ conn.setAutoCommit(false);
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT 1, 2 FROM t1 FOR UPDATE");
+ rs.next();
+ System.out.println("Opened an updatable resultset. Now
trying to drop that table through another Statement");
+ stmt1 = conn.createStatement();
+ try {
+ stmt1.executeUpdate("drop table t1");
+ System.out.println("FAIL!!! drop table should
have failed because the updatable resultset is still open");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("Since autocommit is off, the drop
table exception will NOT result in a runtime rollback and hence updatable
resultset object is still open");
+ rs.deleteRow();
+ rs.close();
+ conn.setAutoCommit(true);
+
+ System.out.println("Positive Test16a - Do deleteRow
within a transaction and then rollback the transaction");
+ reloadData();
+ conn.setAutoCommit(false);
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ System.out.println("Verify that before delete trigger
got fired, row count is 0 in deleteTriggerInsertIntoThisTable");
+ dumpRS(stmt.executeQuery("select count(*) from
deleteTriggerInsertIntoThisTable"));
+ System.out.println("Verify that before deleteRow, row
count is 4 in table0WithTriggers");
+ dumpRS(stmt.executeQuery("select count(*) from
table0WithTriggers"));
+ rs = stmt.executeQuery("SELECT * FROM
table0WithTriggers FOR UPDATE");
+ rs.next();
+ System.out.println("column 1 on this row is " +
rs.getInt(1));
+ System.out.println("now try to delete row and make sure
that trigger got fired");
+ rs.deleteRow();
+ rs.close();
+ System.out.println("Verify that delete trigger got
fired by verifying the row count to be 1 in deleteTriggerInsertIntoThisTable");
+ dumpRS(stmt.executeQuery("select count(*) from
deleteTriggerInsertIntoThisTable"));
+ System.out.println("Verify that deleteRow in
transaction, row count is 3 in table0WithTriggers");
+ dumpRS(stmt.executeQuery("select count(*) from
table0WithTriggers"));
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+ conn.rollback();
+ System.out.println("Verify that after rollback, row
count is back to 0 in deleteTriggerInsertIntoThisTable");
+ dumpRS(stmt.executeQuery("select count(*) from
deleteTriggerInsertIntoThisTable"));
+ System.out.println("Verify that after rollback, row
count is back to 4 in table0WithTriggers");
+ dumpRS(stmt.executeQuery("select count(*) from
table0WithTriggers"));
+ conn.setAutoCommit(true);
+
+ System.out.println("Positive Test16b - Do updateRow
within a transaction and then rollback the transaction");
+ reloadData();
+ conn.setAutoCommit(false);
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ System.out.println("Verify that before update trigger
got fired, row count is 0 in updateTriggerInsertIntoThisTable");
+ dumpRS(stmt.executeQuery("select count(*) from
updateTriggerInsertIntoThisTable"));
+ System.out.println("Look at the data in
table0WithTriggers before trigger gets fired");
+ dumpRS(stmt.executeQuery("select * from
table0WithTriggers"));
+ rs = stmt.executeQuery("SELECT * FROM
table0WithTriggers FOR UPDATE");
+ rs.next();
+ System.out.println("column 1 on this row is " +
rs.getInt(1));
+ System.out.println("now try to update row and make sure
that trigger got fired");
+ rs.updateLong(1,123);
+ rs.updateRow();
+ rs.close();
+ System.out.println("Verify that update trigger got
fired by verifying the row count to be 1 in updateTriggerInsertIntoThisTable");
+ dumpRS(stmt.executeQuery("select count(*) from
updateTriggerInsertIntoThisTable"));
+ System.out.println("Verify that new data in
table0WithTriggers");
+ dumpRS(stmt.executeQuery("select * from
table0WithTriggers"));
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+ conn.rollback();
+ System.out.println("Verify that after rollback, row
count is back to 0 in updateTriggerInsertIntoThisTable");
+ dumpRS(stmt.executeQuery("select count(*) from
updateTriggerInsertIntoThisTable"));
+ System.out.println("Verify that after rollback,
table0WithTriggers is back to its original contents");
+ dumpRS(stmt.executeQuery("select * from
table0WithTriggers"));
+ conn.setAutoCommit(true);
+
+ System.out.println("Positive Test17 - After deleteRow,
resultset is positioned before the next row");
+ reloadData();
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT * FROM t1 FOR UPDATE");
+ rs.next();
+ rs.deleteRow();
+ System.out.println("getXXX right after deleteRow will fail because
resultset is not positioned on a row, instead it is right before the next row");
+ try {
+ System.out.println("column 1 (which is not
nullable) after deleteRow is " + rs.getString(1));
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ rs.close();
+
+ System.out.println("Positive Test18 - Test
cancelRowUpdates method as the first updatable ResultSet api on a read-only
resultset");
+ stmt = conn.createStatement();
+ rs = stmt.executeQuery("SELECT * FROM
AllDataTypesForTestingTable");
+ try {
+ rs.cancelRowUpdates();
+ System.out.println("Test failed - should not
have reached here because cancelRowUpdates is being called on a read-only
resultset");
+ } catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ rs.close();
+
+ System.out.println("Positive Test19 - Test updateRow
method as the first updatable ResultSet api on a read-only resultset");
+ stmt = conn.createStatement();
+ rs = stmt.executeQuery("SELECT * FROM
AllDataTypesForTestingTable");
+ rs.next();
+ try {
+ rs.updateRow();
+ System.out.println("Test failed - should not
have reached here because updateRow is being called on a read-only resultset");
+ return;
+ } catch (Throwable e) {
+ System.out.println(" Got expected exception :
" + e.getMessage());
+ }
+ rs.close();
+
+ System.out.println("Positive Test20 - Test updateXXX
methods as the first updatable ResultSet api on a read-only resultset");
+ conn.setAutoCommit(false);
+ stmt = conn.createStatement();
+ for (int updateXXXName = 1; updateXXXName <=
allUpdateXXXNames.length; updateXXXName++) {
+ System.out.println(" Test " +
allUpdateXXXNames[updateXXXName-1] + " on a readonly resultset");
+ for (int indexOrName = 1; indexOrName <= 2;
indexOrName++) {
+ rs = stmt.executeQuery("SELECT * FROM
AllDataTypesForTestingTable");
+ rs.next();
+ rs1 = stmt1.executeQuery("SELECT * FROM
AllDataTypesNewValuesData");
+ rs1.next();
+ if (indexOrName == 1) //test by passing
column position
+ System.out.println(" Using
column position as first parameter to " + allUpdateXXXNames[updateXXXName-1]);
+ else
+ System.out.println(" Using
column name as first parameter to " + allUpdateXXXNames[updateXXXName-1]);
+ try {
+ if (updateXXXName == 1)
{//update column with updateShort methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateShort(1, rs1.getShort(updateXXXName));
+ else //test by
passing column name
+
rs.updateShort(ColumnNames[0], rs1.getShort(updateXXXName));
+ } else if (updateXXXName == 2){
//update column with updateInt methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateInt(1, rs1.getInt(updateXXXName));
+ else //test by
passing column name
+
rs.updateInt(ColumnNames[0], rs1.getInt(updateXXXName));
+ } else if (updateXXXName ==
3){ //update column with updateLong methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateLong(1, rs1.getLong(updateXXXName));
+ else //test by
passing column name
+
rs.updateLong(ColumnNames[0], rs1.getLong(updateXXXName));
+ } else if (updateXXXName == 4){
//update column with updateBigDecimal methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateBigDecimal(1, rs1.getBigDecimal(updateXXXName));
+ else //test by
passing column name
+
rs.updateBigDecimal(ColumnNames[0], rs1.getBigDecimal(updateXXXName));
+ } else if (updateXXXName == 5){
//update column with updateFloat methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateFloat(1, rs1.getFloat(updateXXXName));
+ else //test by
passing column name
+
rs.updateFloat(ColumnNames[0], rs1.getFloat(updateXXXName));
+ } else if (updateXXXName == 6){
//update column with updateDouble methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateDouble(1, rs1.getDouble(updateXXXName));
+ else //test by
passing column name
+
rs.updateDouble(ColumnNames[0], rs1.getDouble(updateXXXName));
+ } else if (updateXXXName == 7){
//update column with updateString methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateString(1, rs1.getString(updateXXXName));
+ else //test by
passing column name
+
rs.updateString(ColumnNames[0], rs1.getString(updateXXXName));
+ } else if (updateXXXName == 8){
//update column with updateAsciiStream methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateAsciiStream(1,rs1.getAsciiStream(updateXXXName), 4);
+ else //test by
passing column name
+
rs.updateAsciiStream(ColumnNames[0],rs1.getAsciiStream(updateXXXName), 4);
+ } else if (updateXXXName == 9){
//update column with updateCharacterStream methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateCharacterStream(1,rs1.getCharacterStream(updateXXXName), 4);
+ else //test by
passing column name
+
rs.updateCharacterStream(ColumnNames[0],rs1.getCharacterStream(updateXXXName),
4);
+ } else if (updateXXXName ==
10){ //update column with updateByte methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateByte(1,rs1.getByte(1));
+ else //test by
passing column name
+
rs.updateByte(ColumnNames[0],rs1.getByte(1));
+ } else if (updateXXXName ==
11){ //update column with updateBytes methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateBytes(1,rs1.getBytes(updateXXXName));
+ else //test by
passing column name
+
rs.updateBytes(ColumnNames[0],rs1.getBytes(updateXXXName));
+ } else if (updateXXXName ==
12){ //update column with updateBinaryStream methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateBinaryStream(1,rs1.getBinaryStream(updateXXXName), 2);
+ else //test by
passing column name
+
rs.updateBinaryStream(ColumnNames[0],rs1.getBinaryStream(updateXXXName), 2);
+ } else if (updateXXXName ==
13){ //update column with updateClob methods
+ if
(JVMInfo.JDK_ID == 2) //Don't test this method because running JDK1.3 and this
jvm does not support the method
+
continue;
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateClob(1,rs1.getClob(updateXXXName));
+ else //test by
passing column name
+
rs.updateClob(ColumnNames[0],rs1.getClob(updateXXXName));
+ } else if (updateXXXName ==
14){ //update column with updateDate methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateDate(1,rs1.getDate(updateXXXName));
+ else //test by
passing column name
+
rs.updateDate(ColumnNames[0],rs1.getDate(updateXXXName));
+ } else if (updateXXXName ==
15){ //update column with updateTime methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateTime(1,rs1.getTime(updateXXXName));
+ else //test by
passing column name
+
rs.updateTime(ColumnNames[0],rs1.getTime(updateXXXName));
+ } else if (updateXXXName ==
16){ //update column with updateTimestamp methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateTimestamp(1,rs1.getTimestamp(updateXXXName));
+ else //test by
passing column name
+
rs.updateTimestamp(ColumnNames[0],rs1.getTimestamp(updateXXXName));
+ } else if (updateXXXName ==
17){ //update column with updateBlob methods
+ if
(JVMInfo.JDK_ID == 2) //Don't test this method because running JDK1.3 and this
jvm does not support the method
+
continue;
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateBlob(1,rs1.getBlob(updateXXXName));
+ else //test by
passing column name
+
rs.updateBlob(ColumnNames[0],rs1.getBlob(updateXXXName));
+ } else if (updateXXXName ==
18){ //update column with getBoolean methods
+ //use
SHORT sql type column's value for testing boolean since Derby don't support
boolean datatype
+ //Since
Derby does not support Boolean datatype, this method is going to fail with the
syntax error
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateBoolean(1, rs1.getBoolean(1));
+ else //test by
passing column name
+
rs.updateBoolean(ColumnNames[0], rs1.getBoolean(1));
+ } else if (updateXXXName ==
19){ //update column with updateNull methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateNull(1);
+ else //test by
passing column name
+
rs.updateNull(ColumnNames[0]);
+ } else if (updateXXXName ==
20){ //update column with updateArray methods - should get not implemented
exception
+ if
(JVMInfo.JDK_ID == 2) //Don't test this method because running JDK1.3 and this
jvm does not support the method
+
continue;
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateArray(1, null);
+ else //test by
passing column name
+
rs.updateArray(ColumnNames[0], null);
+ } else if (updateXXXName ==
21){ //update column with updateRef methods - should get not implemented
exception
+ if
(JVMInfo.JDK_ID == 2) //Don't test this method because running JDK1.3 and this
jvm does not support the method
+
continue;
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateRef(1, null);
+ else //test by
passing column name
+
rs.updateRef(ColumnNames[0], null);
+ }
+ System.out.println("Test failed
- should not have reached here because updateXXX is being called on a read-only
resultset");
+ return;
+ } catch (Throwable e) {
+ System.out.println("
Got expected exception : " + e.getMessage());
+ }
+ }
+ }
+ conn.setAutoCommit(true);
+
+ System.out.println("Positive Test21 - Test all
updateXXX(excluding updateObject) methods on all the supported sql datatypes");
+ conn.setAutoCommit(false);
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ stmt1 = conn.createStatement();
+ for (int sqlType = 1, checkAgainstColumn = 1; sqlType
<= allSQLTypes.length; sqlType++ ) {
+ System.out.println("Next datatype to test is "
+ allSQLTypes[sqlType-1]);
+ for (int updateXXXName = 1; updateXXXName <=
allUpdateXXXNames.length; updateXXXName++) {
+ checkAgainstColumn = updateXXXName;
+ System.out.println(" Testing " +
allUpdateXXXNames[updateXXXName-1] + " on SQL type " + allSQLTypes[sqlType-1]);
+ for (int indexOrName = 1; indexOrName
<= 2; indexOrName++) {
+ if (indexOrName == 1) //test by
passing column position
+ System.out.println("
Using column position as first parameter to " +
allUpdateXXXNames[updateXXXName-1]);
+ else
+ System.out.println("
Using column name as first parameter to " + allUpdateXXXNames[updateXXXName-1]);
+ rs = stmt.executeQuery("SELECT
* FROM AllDataTypesForTestingTable FOR UPDATE");
+ rs.next();
+ rs1 =
stmt1.executeQuery("SELECT * FROM AllDataTypesNewValuesData");
+ rs1.next();
+ try {
+ if (updateXXXName == 1)
{//update column with updateShort methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateShort(sqlType, rs1.getShort(updateXXXName));
+ else //test by
passing column name
+
rs.updateShort(ColumnNames[sqlType-1], rs1.getShort(updateXXXName));
+ } else if
(updateXXXName == 2){ //update column with updateInt methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateInt(sqlType, rs1.getInt(updateXXXName));
+ else //test by
passing column name
+
rs.updateInt(ColumnNames[sqlType-1], rs1.getInt(updateXXXName));
+ } else if
(updateXXXName == 3){ //update column with updateLong methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateLong(sqlType, rs1.getLong(updateXXXName));
+ else //test by
passing column name
+
rs.updateLong(ColumnNames[sqlType-1], rs1.getLong(updateXXXName));
+ } else if
(updateXXXName == 4){ //update column with updateBigDecimal methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateBigDecimal(sqlType, rs1.getBigDecimal(updateXXXName));
+ else //test by
passing column name
+
rs.updateBigDecimal(ColumnNames[sqlType-1], rs1.getBigDecimal(updateXXXName));
+ } else if
(updateXXXName == 5){ //update column with updateFloat methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateFloat(sqlType, rs1.getFloat(updateXXXName));
+ else //test by
passing column name
+
rs.updateFloat(ColumnNames[sqlType-1], rs1.getFloat(updateXXXName));
+ } else if
(updateXXXName == 6){ //update column with updateDouble methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateDouble(sqlType, rs1.getDouble(updateXXXName));
+ else //test by
passing column name
+
rs.updateDouble(ColumnNames[sqlType-1], rs1.getDouble(updateXXXName));
+ } else if
(updateXXXName == 7){ //update column with updateString methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateString(sqlType, rs1.getString(updateXXXName));
+ else //test by
passing column name
+
rs.updateString(ColumnNames[sqlType-1], rs1.getString(updateXXXName));
+ } else if
(updateXXXName == 8){ //update column with updateAsciiStream methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateAsciiStream(sqlType,rs1.getAsciiStream(updateXXXName), 4);
+ else //test by
passing column name
+
rs.updateAsciiStream(ColumnNames[sqlType-1],rs1.getAsciiStream(updateXXXName),
4);
+ } else if
(updateXXXName == 9){ //update column with updateCharacterStream methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateCharacterStream(sqlType,rs1.getCharacterStream(updateXXXName), 4);
+ else //test by
passing column name
+
rs.updateCharacterStream(ColumnNames[sqlType-1],rs1.getCharacterStream(updateXXXName),
4);
+ } else if
(updateXXXName == 10){ //update column with updateByte methods
+
checkAgainstColumn = 1;
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateByte(sqlType,rs1.getByte(checkAgainstColumn));
+ else //test by
passing column name
+
rs.updateByte(ColumnNames[sqlType-1],rs1.getByte(checkAgainstColumn));
+ } else if
(updateXXXName == 11){ //update column with updateBytes methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateBytes(sqlType,rs1.getBytes(updateXXXName));
+ else //test by
passing column name
+
rs.updateBytes(ColumnNames[sqlType-1],rs1.getBytes(updateXXXName));
+ } else if
(updateXXXName == 12){ //update column with updateBinaryStream methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateBinaryStream(sqlType,rs1.getBinaryStream(updateXXXName), 2);
+ else //test by
passing column name
+
rs.updateBinaryStream(ColumnNames[sqlType-1],rs1.getBinaryStream(updateXXXName),
2);
+ } else if
(updateXXXName == 13){ //update column with updateClob methods
+ if
(JVMInfo.JDK_ID == 2) //Don't test this method because running JDK1.3 and this
jvm does not support the method
+
continue;
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateClob(sqlType,rs1.getClob(updateXXXName));
+ else //test by
passing column name
+
rs.updateClob(ColumnNames[sqlType-1],rs1.getClob(updateXXXName));
+ } else if
(updateXXXName == 14){ //update column with updateDate methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateDate(sqlType,rs1.getDate(updateXXXName));
+ else //test by
passing column name
+
rs.updateDate(ColumnNames[sqlType-1],rs1.getDate(updateXXXName));
+ } else if
(updateXXXName == 15){ //update column with updateTime methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateTime(sqlType,rs1.getTime(updateXXXName));
+ else //test by
passing column name
+
rs.updateTime(ColumnNames[sqlType-1],rs1.getTime(updateXXXName));
+ } else if
(updateXXXName == 16){ //update column with updateTimestamp methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateTimestamp(sqlType,rs1.getTimestamp(updateXXXName));
+ else //test by
passing column name
+
rs.updateTimestamp(ColumnNames[sqlType-1],rs1.getTimestamp(updateXXXName));
+ } else if
(updateXXXName == 17){ //update column with updateBlob methods
+ if
(JVMInfo.JDK_ID == 2) //Don't test this method because running JDK1.3 and this
jvm does not support the method
+
continue;
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateBlob(sqlType,rs1.getBlob(updateXXXName));
+ else //test by
passing column name
+
rs.updateBlob(ColumnNames[sqlType-1],rs1.getBlob(updateXXXName));
+ } else if
(updateXXXName == 18){ //update column with getBoolean methods
+ //use
SHORT sql type column's value for testing boolean since Derby don't support
boolean datatype
+ //Since
Derby does not support Boolean datatype, this method is going to fail with the
syntax error
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateBoolean(sqlType, rs1.getBoolean(1));
+ else //test by
passing column name
+
rs.updateBoolean(ColumnNames[sqlType-1], rs1.getBoolean(1));
+ } else if
(updateXXXName == 19){ //update column with updateNull methods
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateNull(sqlType);
+ else //test by
passing column name
+
rs.updateNull(ColumnNames[sqlType-1]);
+ } else if
(updateXXXName == 20){ //update column with updateArray methods - should get
not implemented exception
+ if
(JVMInfo.JDK_ID == 2) //Don't test this method because running JDK1.3 and this
jvm does not support the method
+
continue;
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateArray(sqlType, null);
+ else //test by
passing column name
+
rs.updateArray(ColumnNames[sqlType-1], null);
+ } else if
(updateXXXName == 21){ //update column with updateRef methods - should get not
implemented exception
+ if
(JVMInfo.JDK_ID == 2) //Don't test this method because running JDK1.3 and this
jvm does not support the method
+
continue;
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateRef(sqlType, null);
+ else //test by
passing column name
+
rs.updateRef(ColumnNames[sqlType-1], null);
+ }
+ rs.updateRow();
+ if
(updateXXXRulesTableForEmbedded[sqlType-1][updateXXXName-1].equals("ERROR")) {
+
System.out.println("FAILURE : We shouldn't reach here. The test should have
failed earlier on updateXXX or updateRow call");
+ return;
+ }
+ if
(verifyData(sqlType,checkAgainstColumn, "AllDataTypesNewValuesData") == false)
+ {
+
System.out.println("Test failed");
+ return;
+ }
+ } catch (Throwable e) {
+ if
(updateXXXRulesTableForEmbedded[sqlType-1][updateXXXName-1].equals("ERROR"))
+
System.out.println(" Got expected exception : " + e.getMessage());
+ else {
+ if ((sqlType ==
14 || sqlType == 15 || sqlType == 16) && //we are dealing with
DATE/TIME/TIMESTAMP column types
+
checkAgainstColumn == 7) //we are dealing with updateString. The failure is
because string does not represent a valid datetime value
+
System.out.println(" Got expected exception : " + e.getMessage());
+ else {
+
System.out.println(" Got UNexpected exception : " + e.getMessage());
+ return;
+ }
+ }
+ }
+ }
+ rs.close();
+ rs1.close();
+ }
+ }
+ conn.setAutoCommit(true);
+
+ System.out.println("Positive Test22 - Test updateObject
method");
+ conn.setAutoCommit(false);
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ stmt1 = conn.createStatement();
+ String displayString;
+ for (int sqlType = 1; sqlType <= allSQLTypes.length;
sqlType++ ) {
+ System.out.println("Next datatype to test is "
+ allSQLTypes[sqlType-1]);
+ for (int updateXXXName = 1; updateXXXName <=
allUpdateXXXNames.length; updateXXXName++) {
+ for (int indexOrName = 1; indexOrName
<= 2; indexOrName++) {
+ if (indexOrName == 1) //test by
passing column position
+ displayString = "
updateObject with column position &";
+ else
+ displayString = "
updateObject with column name &";
+ rs = stmt.executeQuery("SELECT
* FROM AllDataTypesForTestingTable FOR UPDATE");
+ rs.next();
+ rs1 =
stmt1.executeQuery("SELECT * FROM AllDataTypesNewValuesData");
+ rs1.next();
+ try {
+ if (updateXXXName ==
1){ //updateObject using Short object
+
System.out.println(displayString + " Short object as parameters");
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateObject(sqlType, new Short(rs1.getShort(updateXXXName)));
+ else //test by
passing column name
+
rs.updateObject(ColumnNames[sqlType-1], new Short(rs1.getShort(updateXXXName)));
+ } else if
(updateXXXName == 2){ //updateObject using Integer object
+
System.out.println(displayString + " Integer object as parameters");
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateObject(sqlType, new Integer(rs1.getInt(updateXXXName)));
+ else //test by
passing column name
+
rs.updateObject(ColumnNames[sqlType-1], new Integer(rs1.getInt(updateXXXName)));
+ } else if
(updateXXXName == 3){ //updateObject using Long object
+
System.out.println(displayString + " Long object as parameters");
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateObject(sqlType, new Long(rs1.getLong(updateXXXName)));
+ else //test by
passing column name
+
rs.updateObject(ColumnNames[sqlType-1], new Long(rs1.getLong(updateXXXName)));
+ } else if
(updateXXXName == 4){ //updateObject using BigDecimal object
+
System.out.println(displayString + " BigDecimal object as parameters");
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateObject(sqlType, rs1.getBigDecimal(updateXXXName));
+ else //test by
passing column name
+
rs.updateObject(ColumnNames[sqlType-1], rs1.getBigDecimal(updateXXXName));
+ } else if
(updateXXXName == 5){ //updateObject using Float object
+
System.out.println(displayString + " Float object as parameters");
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateObject(sqlType, new Float(rs1.getFloat(updateXXXName)));
+ else //test by
passing column name
+
rs.updateObject(ColumnNames[sqlType-1], new Float(rs1.getFloat(updateXXXName)));
+ } else if
(updateXXXName == 6){ //updateObject using Double object
+
System.out.println(displayString + " Double object as parameters");
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateObject(sqlType, new Double(rs1.getDouble(updateXXXName)));
+ else //test by
passing column name
+
rs.updateObject(ColumnNames[sqlType-1], new
Double(rs1.getDouble(updateXXXName)));
+ } else if
(updateXXXName == 7){ //updateObject using String object
+
System.out.println(displayString + " String object as parameters");
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateObject(sqlType,rs1.getString(updateXXXName));
+ else //test by
passing column name
+
rs.updateObject(ColumnNames[sqlType-1],rs1.getString(updateXXXName));
+ } else if
(updateXXXName == 8 || updateXXXName == 12) //updateObject does not accept
InputStream and hence this is a no-op
+
continue;
+ else if (updateXXXName
== 9) //updateObject does not accept Reader and hence this is a no-op
+
continue;
+ else if (updateXXXName
== 10) //update column with updateByte methods
+
//non-Object parameter(which is byte in this cas) can't be passed to
updateObject mthod
+
continue;
+ else if (updateXXXName
== 11){ //update column with updateBytes methods
+
System.out.println(displayString + " bytes[] array as parameters");
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateObject(sqlType,rs1.getBytes(updateXXXName));
+ else //test by
passing column name
+
rs.updateObject(ColumnNames[sqlType-1], rs1.getBytes(updateXXXName));
+ } else if
(updateXXXName == 13){ //update column with updateClob methods
+ if
(JVMInfo.JDK_ID == 2) //Don't test this method because running JDK1.3 and this
jvm does not support the method
+
continue;
+
System.out.println(displayString + " Clob object as parameters");
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateObject(sqlType, rs1.getClob(updateXXXName));
+ else //test by
passing column name
+
rs.updateObject(ColumnNames[sqlType-1], rs1.getClob(updateXXXName));
+ } else if
(updateXXXName == 14){ //update column with updateDate methods
+
System.out.println(displayString + " Date object as parameters");
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateObject(sqlType, rs1.getDate(updateXXXName));
+ else //test by
passing column name
+
rs.updateObject(ColumnNames[sqlType-1], rs1.getDate(updateXXXName));
+ } else if
(updateXXXName == 15){ //update column with updateTime methods
+
System.out.println(displayString + " Time object as parameters");
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateObject(sqlType, rs1.getTime(updateXXXName));
+ else //test by
passing column name
+
rs.updateObject(ColumnNames[sqlType-1], rs1.getTime(updateXXXName));
+ } else if
(updateXXXName == 16){ //update column with updateTimestamp methods
+
System.out.println(displayString + " TimeStamp object as parameters");
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateObject(sqlType, rs1.getTimestamp(updateXXXName));
+ else //test by
passing column name
+
rs.updateObject(ColumnNames[sqlType-1], rs1.getTimestamp(updateXXXName));
+ } else if
(updateXXXName == 17){ //update column with updateBlob methods
+ if
(JVMInfo.JDK_ID == 2) //Don't test this method because running JDK1.3 and this
jvm does not support the method
+
continue;
+
System.out.println(displayString + " Blob object as parameters");
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateObject(sqlType, rs1.getBlob(updateXXXName));
+ else //test by
passing column name
+
rs.updateObject(ColumnNames[sqlType-1], rs1.getBlob(updateXXXName));
+ } else if
(updateXXXName == 18) {//update column with getBoolean methods
+
System.out.println(displayString + " Boolean object as parameters");
+ //use
SHORT sql type column's value for testing boolean since Derby don't support
boolean datatype
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateObject(sqlType, new Boolean(rs1.getBoolean(1)));
+ else //test by
passing column name
+
rs.updateObject(ColumnNames[sqlType-1], new Boolean(rs1.getBoolean(1)));
+ } else if
(updateXXXName == 19){ //update column with updateNull methods
+
System.out.println(displayString + " null as parameters");
+ if (indexOrName
== 1) //test by passing column position
+
rs.updateObject(sqlType, null);
+ else //test by
passing column name
+
rs.updateObject(ColumnNames[sqlType-1], null);
+ } else if
(updateXXXName == 20 || updateXXXName == 21) //since Derby does not support
Array, Ref datatype, this is a no-op
+
continue;
+
+ rs.updateRow();
+ if
(updateXXXRulesTableForEmbedded[sqlType-1][updateXXXName-1].equals("ERROR")) {
+
System.out.println("FAILURE : We shouldn't reach here. The test should have
failed earlier on updateXXX or updateRow call");
+ return;
+ }
+ if
(verifyData(sqlType,updateXXXName, "AllDataTypesNewValuesData") == false)
+ {
+
System.out.println("Test failed");
+ return;
+ }
+ } catch (Throwable e) {
+ if
(updateXXXRulesTableForEmbedded[sqlType-1][updateXXXName-1].equals("ERROR"))
+
System.out.println(" Got expected exception : " + e.getMessage());
+ else {
+ if
((sqlType == 14 || sqlType == 15 || sqlType == 16) && //we are dealing with
DATE/TIME/TIMESTAMP column types
+
updateXXXName == 7) //we are dealing with updateString. The failure is because
string does not represent a valid datetime value
+
System.out.println(" Got expected exception : " + e.getMessage());
+ else {
+
System.out.println(" Got UNexpected exception : " + e.getMessage());
+ return;}
+ }
+ }
+ rs.close();
+ rs1.close();
+ }
+ }
+ }
+ conn.setAutoCommit(true);
+
+ System.out.println("Positive Test23 - Test
cancelRowUpdates after updateXXX methods on all the supported sql datatypes");
+ conn.setAutoCommit(false);
+ reloadAllDataTypesForTestingTableData();
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ stmt1 = conn.createStatement();
+ rs = stmt.executeQuery("SELECT * FROM
AllDataTypesForTestingTable FOR UPDATE");
+ rs.next();
+ rs1 = stmt1.executeQuery("SELECT * FROM
AllDataTypesNewValuesData");
+ rs1.next();
+
+ System.out.println(" updateShort and then
cancelRowUpdates");
+ short s = rs.getShort(1);
+ rs.updateShort(1, rs1.getShort(1));
+ if(rs.getShort(1) != rs1.getShort(1))
+ return;
+ rs.cancelRowUpdates();
+ if(rs.getShort(1) != s)
+ return;
+
+ System.out.println(" updateInt and then
cancelRowUpdates");
+ int i = rs.getInt(2);
+ rs.updateInt(2, rs1.getInt(2));
+ if(rs.getInt(2) != rs1.getInt(2))
+ return;
+ rs.cancelRowUpdates();
+ if(rs.getInt(2) != i)
+ return;
+
+ System.out.println(" updateLong and then
cancelRowUpdates");
+ long l = rs.getLong(3);
+ rs.updateLong(3, rs1.getLong(3));
+ if(rs.getLong(3) != rs1.getLong(3))
+ return;
+ rs.cancelRowUpdates();
+ if(rs.getLong(3) != l)
+ return;
+
+ System.out.println(" updateBigDecimal and then
cancelRowUpdates");
+ BigDecimal bd = rs.getBigDecimal(4);
+ rs.updateBigDecimal(4, rs1.getBigDecimal(4));
+ if(rs.getBigDecimal(4).compareTo(rs1.getBigDecimal(4))
!= 0)
+ return;
+ rs.cancelRowUpdates();
+ if(rs.getBigDecimal(4) != bd)
+ return;
+
+ System.out.println(" updateFloat and then
cancelRowUpdates");
+ float f = rs.getFloat(5);
+ rs.updateFloat(5, rs1.getFloat(5));
+ if(rs.getFloat(5) != rs1.getFloat(5))
+ return;
+ rs.cancelRowUpdates();
+ if(rs.getFloat(5) != f)
+ return;
+
+ System.out.println(" updateDouble and then
cancelRowUpdates");
+ double db = rs.getDouble(6);
+ rs.updateDouble(6, rs1.getDouble(6));
+ if(rs.getDouble(6) != rs1.getDouble(6))
+ return;
+ rs.cancelRowUpdates();
+ if(rs.getDouble(6) != db)
+ return;
+
+ System.out.println(" updateString and then
cancelRowUpdates");
+ String str = rs.getString(7);
+ rs.updateString(7, rs1.getString(7));
+ if(!rs.getString(7).equals(rs1.getString(7)))
+ return;
+ rs.cancelRowUpdates();
+ if(!rs.getString(7).equals(str))
+ return;
+
+ System.out.println(" updateAsciiStream and then
cancelRowUpdates");
+ str = rs.getString(8);
+ rs.updateAsciiStream(8,rs1.getAsciiStream(8), 4);
+ if(!rs.getString(8).equals(rs1.getString(8)))
+ return;
+ rs.cancelRowUpdates();
+ if(!rs.getString(8).equals(str))
+ return;
+
+ System.out.println(" updateCharacterStream and then
cancelRowUpdates");
+ str = rs.getString(9);
+ rs.updateCharacterStream(9,rs1.getCharacterStream(9),
4);
+ if(!rs.getString(9).equals(rs1.getString(9)))
+ return;
+ rs.cancelRowUpdates();
+ if(!rs.getString(9).equals(str))
+ return;
+
+ System.out.println(" updateByte and then
cancelRowUpdates");
+ s = rs.getShort(1);
+ rs.updateByte(1,rs1.getByte(1));
+ if(rs.getShort(1) != rs1.getShort(1))
+ return;
+ rs.cancelRowUpdates();
+ if(rs.getShort(1) != s)
+ return;
+
+ System.out.println(" updateBytes and then
cancelRowUpdates");
+ byte[] bts = rs.getBytes(11);
+ rs.updateBytes(11,rs1.getBytes(11));
+ if
(!(java.util.Arrays.equals(rs.getBytes(11),rs1.getBytes(11))))
+ return;
+ rs.cancelRowUpdates();
+ if (!(java.util.Arrays.equals(rs.getBytes(11),bts)))
+ return;
+
+ System.out.println(" updateBinaryStream and then
cancelRowUpdates");
+ bts = rs.getBytes(12);
+ rs.updateBinaryStream(12,rs1.getBinaryStream(12), 2);
+ if
(!(java.util.Arrays.equals(rs.getBytes(12),rs1.getBytes(12))))
+ return;
+ rs.cancelRowUpdates();
+ if (!(java.util.Arrays.equals(rs.getBytes(12),bts)))
+ return;
+
+ System.out.println(" updateDate and then
cancelRowUpdates");
+ Date date = rs.getDate(14);
+ rs.updateDate(14,rs1.getDate(14));
+ if(rs.getDate(14).compareTo(rs1.getDate(14)) != 0)
+ return;
+ rs.cancelRowUpdates();
+ if(rs.getDate(14).compareTo(date) != 0)
+ return;
+
+ System.out.println(" updateTime and then
cancelRowUpdates");
+ Time time = rs.getTime(15);
+ rs.updateTime(15,rs1.getTime(15));
+ if(rs.getTime(15).compareTo(rs1.getTime(15)) != 0)
+ return;
+ rs.cancelRowUpdates();
+ if(rs.getTime(15).compareTo(time) != 0)
+ return;
+
+ System.out.println(" updateTimestamp and then
cancelRowUpdates");
+ Timestamp timeStamp = rs.getTimestamp(16);
+ rs.updateTimestamp(16,rs1.getTimestamp(16));
+
if(!rs.getTimestamp(16).toString().equals(rs1.getTimestamp(16).toString()))
+ return;
+ rs.cancelRowUpdates();
+
if(!rs.getTimestamp(16).toString().equals(timeStamp.toString()))
+ return;
+
+ if (JVMInfo.JDK_ID != 2){ //Don't test this method when
running JDK1.3 because jdk1.3 does not support the method
+ System.out.println(" updateClob and then
cancelRowUpdates");
+ String clb1 = rs.getString(13);
+ rs.updateClob(13,rs1.getClob(13));
+ if(!rs.getString(13).equals(rs1.getString(13)))
+ return;
+ rs.cancelRowUpdates();
+ if(!rs.getString(13).equals(clb1))
+ return;
+ System.out.println(" updateBlob and then
cancelRowUpdates");
+ bts = rs.getBytes(17);
+ rs.updateBlob(17,rs1.getBlob(17));
+ if
(!(java.util.Arrays.equals(rs.getBytes(17),rs1.getBytes(17))))
+ return;
+ rs.cancelRowUpdates();
+ if
(!(java.util.Arrays.equals(rs.getBytes(17),bts)))
+ return;
+ }
+
+ rs.close();
+ rs1.close();
+ conn.setAutoCommit(true);
+
+ System.out.println("Positive Test24a - after updateXXX,
try cancelRowUpdates and then deleteRow");
+ reloadData();
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT * FROM t1 FOR UPDATE");
+ rs.next();
+ System.out.println("column 1 on this row before
updateInt is " + rs.getInt(1));
+ rs.updateInt(1,234);
+ System.out.println("column 1 on this row after
updateInt is " + rs.getInt(1));
+ System.out.println("now cancelRowUpdates on the row");
+ rs.cancelRowUpdates();
+ System.out.println("Since after cancelRowUpdates(),
ResultSet is positioned on the same row, getXXX will pass");
+ System.out.println("column 1 on this row after
cancelRowUpdates is " + rs.getInt(1));
+ System.out.println("Since after cancelRowUpdates(),
ResultSet is positioned on the same row, a deleteRow at this point will pass");
+ try {
+ rs.deleteRow();
+ System.out.println("PASS : deleteRow passed as
expected");
+ }
+ catch (SQLException e) {
+ dumpSQLExceptions(e);
+ }
+ System.out.println("calling updateRow after deleteRow
w/o first positioning the ResultSet on the next row will fail");
+ try {
+ rs.updateRow();
+ System.out.println("FAIL!!! updateRow should
have failed because ResultSet is not positioned on a row");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ System.out.println("Position the ResultSet with
next()");
+ rs.next();
+ System.out.println("Should be able to updateRow() on
the current row now");
+ rs.updateString(2,"234");
+ rs.updateRow();
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ System.out.println("Positive Test25 - issue
cancelRowUpdates without any updateXXX");
+ reloadData();
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT * FROM t1 FOR UPDATE");
+ rs.next();
+ rs.cancelRowUpdates();
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ System.out.println("Positive Test26 - issue updateRow
without any updateXXX will not move the resultset position");
+ reloadData();
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT * FROM t1 FOR UPDATE");
+ rs.next();
+ rs.updateRow(); //this will not move the resultset to
right before the next row because there were no updateXXX issued before
updateRow
+ rs.updateRow();
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ System.out.println("Positive Test27 - issue updateXXX
and then deleteRow");
+ reloadData();
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT * FROM t1 FOR UPDATE");
+ rs.next();
+ rs.updateInt(1,1234);
+ rs.updateString(2,"aaaaa");
+ rs.deleteRow();
+ try {
+ rs.updateRow();
+ System.out.println("FAIL!!! deleteRow should
have moved the ResultSet to right before the next row");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ try {
+ rs.updateInt(1,2345);
+ System.out.println("FAIL!!! deleteRow should
have moved the ResultSet to right before the next row");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ try {
+ rs.getInt(1);
+ System.out.println("FAIL!!! deleteRow should
have moved the ResultSet to right before the next row");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+
+ System.out.println("Positive Test28 - issue updateXXXs
and then move off the row, the changes should be ignored");
+ reloadData();
+ dumpRS(stmt.executeQuery("select * from t1"));
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT * FROM t1 FOR UPDATE");
+ rs.next();
+ System.out.println(" column 1 on this row before
updateInt is " + rs.getInt(1));
+ System.out.println(" Issue updateInt to change the
column's value to 2345");
+ rs.updateInt(1,2345);
+ System.out.println(" Move to next row w/o issuing
updateRow");
+ rs.next(); //the changes made on the earlier row should
have be ignored because we moved off that row without issuing updateRow
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+ System.out.println(" Make sure that changes didn't
make it to the database");
+ dumpRS(stmt.executeQuery("select * from t1"));
+
+ System.out.println("Positive Test29 - issue multiple
updateXXXs and then a updateRow");
+ reloadData();
+ dumpRS(stmt.executeQuery("select * from t1"));
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT * FROM t1 FOR UPDATE");
+ rs.next();
+ System.out.println(" column 1 on this row before
updateInt is " + rs.getInt(1));
+ System.out.println(" Issue updateInt to change the
column's value to 2345");
+ rs.updateInt(1,2345);
+ System.out.println(" Issue another updateInt on the
same row and column to change the column's value to 9999");
+ rs.updateInt(1,9999);
+ System.out.println(" Issue updateString to change the
column's value to 'xxxxxxx'");
+ rs.updateString(2,"xxxxxxx");
+ System.out.println(" Now issue updateRow");
+ rs.updateRow();
+ //have to close the resultset because by default,
resultsets are held open over commit
+ rs.close();
+ System.out.println(" Make sure that changes made it to
the database correctly");
+ dumpRS(stmt.executeQuery("select * from t1"));
+
+ System.out.println("Positive Test30 - call updateXXX
methods on only columns that correspond to a column in the table");
+ dumpRS(stmt.executeQuery("select * from t1"));
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT 1, 2, c1, c2 FROM t1 FOR
UPDATE");
+ rs.next();
+ rs.updateInt(3,22);
+ rs.updateRow();
+ rs.close();
+ System.out.println(" Make sure that changes made it to
the database correctly");
+ dumpRS(stmt.executeQuery("select * from t1"));
+
+ System.out.println("Positive Test31a - case sensitive
table and column names");
+ stmt.executeUpdate("create table \"t1\" (\"c11\" int,
c12 int)");
+ stmt.executeUpdate("insert into \"t1\" values(1, 2),
(2,3)");
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT \"c11\", \"C12\" FROM
\"t1\" FOR UPDATE");
+ rs.next();
+ rs.updateInt(1,11);
+ rs.updateInt(2,22);
+ rs.updateRow();
+ rs.next();
+ rs.deleteRow();
+ rs.close();
+ System.out.println(" Make sure that changes made it to
the database correctly");
+ dumpRS(stmt.executeQuery("select * from \"t1\""));
+
+ System.out.println("Positive Test31b - table and column
names with spaces in middle and end");
+ stmt.executeUpdate("create table \" t 11 \" (\" c 111
\" int, c112 int)");
+ stmt.executeUpdate("insert into \" t 11 \" values(1,
2), (2,3)");
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT \" c 111 \", \"C112\"
FROM \" t 11 \" FOR UPDATE");
+ rs.next();
+ rs.updateInt(1,11);
+ rs.updateInt(2,22);
+ rs.updateRow();
+ rs.next();
+ rs.deleteRow();
+ rs.close();
+ System.out.println(" Make sure for table \" t 11 \"
that changes made it to the database correctly");
+ dumpRS(stmt.executeQuery("select * from \" t 11 \""));
+
+ System.out.println("Positive Test32 - call updateXXX
methods on column that is not in for update columns list");
+ dumpRS(stmt.executeQuery("select * from t1"));
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ rs = stmt.executeQuery("SELECT c1, c2 FROM t1 FOR
UPDATE of c1");
+ rs.next();
+ try {
+ rs.updateInt(2,22);
+ System.out.println("FAIL!!! updateInt should
have failed because c12 is not the FOR UPDATE columns list.");
+ }
+ catch (SQLException e) {
+ System.out.println("SQL State : " +
e.getSQLState());
+ System.out.println("Got expected exception " +
e.getMessage());
+ }
+ rs.close();
+ System.out.println(" Make sure the contents of table
are unchanged");
+ dumpRS(stmt.executeQuery("select * from t1"));
+
+ System.out.println("Positive Test33 - try to update a
table from another schema");
+ System.out.println(" contents of table t1 from current
schema");
+ dumpRS(stmt.executeQuery("select * from t1"));
+ stmt =
conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
+ stmt.executeUpdate("create schema s2");
+ stmt.executeUpdate("create table s2.t1 (c1s2t1 int,
c2s2t1 smallint, c3s2t2 double)");
+ stmt.executeUpdate("insert into s2.t1
values(1,2,2.2),(1,3,3.3)");
+ System.out.println(" contents of table t1 from schema
s2");
+ dumpRS(stmt.executeQuery("select * from s2.t1"));
+ System.out.println(" Try to change contents of 2nd
column of s2.t1 using updateRow");
+ rs = stmt.executeQuery("SELECT * FROM s2.t1 FOR
UPDATE");
+ rs.next();
+ rs.updateInt(2,1);
+ rs.updateRow();
+ rs.next();
+ rs.updateInt(2,1);
+ rs.updateRow();
+ rs.close();
+ System.out.println(" Make sure that changes made to
the right table t1");
+ System.out.println(" contents of table t1 from current
schema should have remained unchanged");
+ dumpRS(stmt.executeQuery("select * from t1"));
+ System.out.println(" contents of table t1 from schema
s2 should have changed");
+ dumpRS(stmt.executeQuery("select * from s2.t1"));
+
+ teardown();
+ }
+
+ conn.close();
+
+ } catch (Throwable e) {
+ System.out.println("FAIL: exception thrown:");
+ JDBCDisplayUtil.ShowException(System.out,e);
+ }
+
+ System.out.println("Finished testing updateable resultsets");
+ }
+
+ static boolean verifyData(int sqlType, int updateXXXName, String
checkAgainstTheTable) throws SQLException {
+ Statement stmt1 = conn.createStatement();
+ ResultSet rs1 = stmt1.executeQuery("select * from " +
checkAgainstTheTable);
+ rs1.next();
+ Statement stmt = conn.createStatement();
+ ResultSet rs = stmt.executeQuery("select * from
AllDataTypesForTestingTable");
+ rs.next();
+
+ if (updateXXXName == 18){ //verifying updateBoolean
+ if(rs.getBoolean(sqlType) != rs1.getBoolean(1))
+ return(false);
+ else
+ return(true);
+ }
+
+ if (updateXXXName == 19){ //verifying updateNull
+ if(rs.getObject(sqlType) == null && rs.wasNull())
+ return(true);
+ else
+ return(false);
+ }
+
+ if (sqlType == 1) //verify update made to SMALLINT column with
updateXXX methods
+ if(rs.getShort(sqlType) != rs1.getShort(updateXXXName))
{
+ return(false); }
+ else if (sqlType == 2) //verify update made to INTEGER column
with updateXXX methods
+ if(rs.getInt(sqlType) != rs1.getInt(updateXXXName)) {
+ return(false); }
+ else if (sqlType == 3) //verify update made to BIGINT column
with updateXXX methods
+ if(rs.getLong(sqlType) != rs1.getLong(updateXXXName)) {
+ return(false); }
+ else if (sqlType == 4) //verify update made to DECIMAL column
with updateXXX methods
+ if(rs.getBigDecimal(sqlType) !=
rs1.getBigDecimal(updateXXXName)) {
+ return(false); }
+ else if (sqlType == 5) //verify update made to REAL column
with updateXXX methods
+ if(rs.getFloat(sqlType) != rs1.getFloat(updateXXXName))
{
+ return(false); }
+ else if (sqlType == 6) //verify update made to DOUBLE column
with updateXXX methods
+ if(rs.getDouble(sqlType) !=
rs1.getDouble(updateXXXName)) {
+ return(false); }
+ else if (sqlType == 7 || sqlType == 8 || sqlType == 9)
//verify update made to CHAR/VARCHAR/LONG VARCHAR column with updateXXX methods
+
if(!rs.getString(sqlType).equals(rs1.getString(updateXXXName))) {
+ return(false); }
+ else if (sqlType == 10 || sqlType == 11 || sqlType == 12)
//verify update made to CHAR/VARCHAR/LONG VARCHAR FOR BIT DATA column with
updateXXX methods
+ if(rs.getBytes(sqlType) != rs1.getBytes(updateXXXName))
{
+ return(false); }
+ else if (sqlType == 13 && JVMInfo.JDK_ID != 2) //verify update
made to CLOB column with updateXXX methods
+
if(!rs.getClob(sqlType).getSubString(1,4).equals(rs1.getClob(updateXXXName).getSubString(1,4)))
{
+ return(false); }
+ else if (sqlType == 14) //verify update made to DATE column
with updateXXX methods
+ if(rs.getDate(sqlType) != rs1.getDate(updateXXXName)) {
+ return(false); }
+ else if (sqlType == 15) //verify update made to TIME column
with updateXXX methods
+ if(rs.getTime(sqlType) != rs1.getTime(updateXXXName)) {
+ return(false); }
+ else if (sqlType == 16) //verify update made to TIMESTAMP
column with updateXXX methods
+ if(rs.getTimestamp(sqlType) !=
rs1.getTimestamp(updateXXXName)) {
+ return(false); }
+ else if (sqlType == 17 && JVMInfo.JDK_ID != 2) //verify update
made to BLOB column with updateXXX methods
+ if(rs.getBlob(sqlType).getBytes(1,4) !=
rs1.getBlob(updateXXXName).getBytes(1,4)) {
+ return(false); }
+
+ stmt.executeUpdate("delete from AllDataTypesForTestingTable");
+ StringBuffer insertSQL = new StringBuffer("insert into
AllDataTypesForTestingTable values(");
+ for (int type = 0; type < allSQLTypes.length - 1; type++)
+ {
+ insertSQL.append(SQLData[type][0] + ",");
+ }
+ insertSQL.append("cast("+SQLData[allSQLTypes.length - 1][0]+"
as BLOB(1K)))");
+ stmt.executeUpdate(insertSQL.toString());
+ return(true);
+ }
+
+ // lifted from the autoGeneratedJdbc30 test
+ public static void dumpRS(ResultSet s) throws SQLException
+ {
+ if (s == null)
+ {
+ System.out.println("<NULL>");
+ return;
+ }
+
+ ResultSetMetaData rsmd = s.getMetaData();
+
+ // Get the number of columns in the result set
+ int numCols = rsmd.getColumnCount();
+
+ if (numCols <= 0)
+ {
+ System.out.println("(no columns!)");
+ return;
+ }
+
+ StringBuffer heading = new StringBuffer("\t ");
+ StringBuffer underline = new StringBuffer("\t ");
+
+ int len;
+ // Display column headings
+ for (int i=1; i<=numCols; i++)
+ {
+ if (i > 1)
+ {
+ heading.append(",");
+ underline.append(" ");
+ }
+ len = heading.length();
+ heading.append(rsmd.getColumnLabel(i));
+ len = heading.length() - len;
+ for (int j = len; j > 0; j--)
+ {
+ underline.append("-");
+ }
+ }
+ System.out.println(heading.toString());
+ System.out.println(underline.toString());
+
+
+ StringBuffer row = new StringBuffer();
+ // Display data, fetching until end of the result set
+ while (s.next())
+ {
+ row.append("\t{");
+ // Loop through each column, getting the
+ // column data and displaying
+ for (int i=1; i<=numCols; i++)
+ {
+ if (i > 1) row.append(",");
+ row.append(s.getString(i));
+ }
+ row.append("}\n");
+ }
+ System.out.println(row.toString());
+ s.close();
+ }
+
+ static void reloadAllDataTypesForTestingTableData() throws SQLException
{
+ Statement stmt = conn.createStatement();
+ stmt.executeUpdate("delete from t1");
+ stmt.executeUpdate("delete from AllDataTypesForTestingTable");
+ StringBuffer insertSQL = new StringBuffer("insert into
AllDataTypesForTestingTable values(");
+ for (int type = 0; type < allSQLTypes.length - 1; type++)
+ insertSQL.append(SQLData[type][0] + ",");
+ insertSQL.append("cast("+SQLData[allSQLTypes.length - 1][0]+"
as BLOB(1K)))");
+ stmt.executeUpdate(insertSQL.toString());
+ }
+
+ static void reloadData() throws SQLException {
+ Statement stmt = conn.createStatement();
+ stmt.executeUpdate("delete from t1");
+ stmt.executeUpdate("insert into t1 values (1,'aa'), (2,'bb'),
(3,'cc')");
+ stmt.executeUpdate("delete from t3");
+ stmt.executeUpdate("insert into t3 values (1,1), (2,2)");
+ stmt.executeUpdate("delete from table0WithTriggers");
+ stmt.executeUpdate("insert into table0WithTriggers values (1,
1), (2, 2), (3, 3), (4, 4)");
+ stmt.executeUpdate("delete from table1WithTriggers");
+ stmt.executeUpdate("insert into table1WithTriggers values (1,
1), (2, 2), (3, 3), (4, 4)");
+ stmt.executeUpdate("delete from table2WithTriggers");
+ stmt.executeUpdate("insert into table2WithTriggers values (1,
1), (2, 2), (3, 3), (4, 4)");
+ stmt.executeUpdate("delete from
deleteTriggerInsertIntoThisTable");
+ stmt.executeUpdate("delete from
updateTriggerInsertIntoThisTable");
+ }
+
+ static void setup(boolean first) throws SQLException {
+ Statement stmt = conn.createStatement();
+ stmt.executeUpdate("create table t1 (c1 int, c2 char(20))");
+ stmt.executeUpdate("create view v1 as select * from t1");
+ stmt.executeUpdate("create table t2 (c21 int, c22 int)");
+ stmt.executeUpdate("create table t3 (c31 int not null primary
key, c32 smallint)");
+ stmt.executeUpdate("create table tableWithPrimaryKey (c1 int
not null, c2 int not null, constraint pk primary key(c1,c2))");
+ stmt.executeUpdate("create table tableWithConstraint (c1 int,
c2 int, constraint fk foreign key(c1,c2) references tableWithPrimaryKey)");
+ stmt.executeUpdate("create table table0WithTriggers (c1 int, c2
bigint)");
+ stmt.executeUpdate("create table
deleteTriggerInsertIntoThisTable (c1 int)");
+ stmt.executeUpdate("create table
updateTriggerInsertIntoThisTable (c1 int)");
+ stmt.executeUpdate("create trigger tr1 after delete on
table0WithTriggers for each statement mode db2sql insert into
deleteTriggerInsertIntoThisTable values (1)");
+ stmt.executeUpdate("create trigger tr2 after update on
table0WithTriggers for each statement mode db2sql insert into
updateTriggerInsertIntoThisTable values (1)");
+ stmt.executeUpdate("create table table1WithTriggers (c1 int, c2
bigint)");
+ stmt.executeUpdate("create trigger tr3 after delete on
table1WithTriggers for each statement mode db2sql delete from
table1WithTriggers");
+ stmt.executeUpdate("create table table2WithTriggers (c1 int, c2
bigint)");
+ stmt.executeUpdate("create trigger tr4 after update on
table2WithTriggers for each statement mode db2sql update table2WithTriggers set
c1=1");
+ stmt.executeUpdate("create table selfReferencingT1 (c1 char(2)
not null, c2 char(2), constraint selfReferencingT1 primary key(c1), constraint
manages1 foreign key(c2) references selfReferencingT1(c1) on delete cascade)");
+ stmt.executeUpdate("create table selfReferencingT2 (c1 char(2)
not null, c2 char(2), constraint selfReferencingT2 primary key(c1), constraint
manages2 foreign key(c2) references selfReferencingT2(c1) on update restrict)");
+
+ stmt.executeUpdate("insert into t1 values (1,'aa')");
+ stmt.executeUpdate("insert into t1 values (2,'bb')");
+ stmt.executeUpdate("insert into t1 values (3,'cc')");
+ stmt.executeUpdate("insert into t2 values (1,1)");
+ stmt.executeUpdate("insert into t3 values (1,1)");
+ stmt.executeUpdate("insert into t3 values (2,2)");
+ stmt.executeUpdate("insert into tableWithPrimaryKey values (1,
1), (2, 2), (3, 3), (4, 4)");
+ stmt.executeUpdate("insert into tableWithConstraint values (1,
1), (2, 2), (3, 3), (4, 4)");
+ stmt.executeUpdate("insert into table0WithTriggers values (1,
1), (2, 2), (3, 3), (4, 4)");
+ stmt.executeUpdate("insert into table1WithTriggers values (1,
1), (2, 2), (3, 3), (4, 4)");
+ stmt.executeUpdate("insert into table2WithTriggers values (1,
1), (2, 2), (3, 3), (4, 4)");
+ stmt.executeUpdate("insert into selfReferencingT1 values ('e1',
null), ('e2', 'e1'), ('e3', 'e2'), ('e4', 'e3')");
+ stmt.executeUpdate("insert into selfReferencingT2 values ('e1',
null), ('e2', 'e1'), ('e3', 'e2'), ('e4', 'e3')");
+
+ StringBuffer createSQL = new StringBuffer("create table
AllDataTypesForTestingTable (");
+ StringBuffer createTestDataSQL = new StringBuffer("create table
AllDataTypesNewValuesData (");
+ for (int type = 0; type < allSQLTypes.length - 1; type++)
+ {
+ createSQL.append(ColumnNames[type] + " " +
allSQLTypes[type] + ",");
+ createTestDataSQL.append(ColumnNames[type] + " " +
allSQLTypes[type] + ",");
+ }
+ createSQL.append(ColumnNames[allSQLTypes.length - 1] + " " +
allSQLTypes[allSQLTypes.length - 1] + ")");
+ createTestDataSQL.append(ColumnNames[allSQLTypes.length - 1] +
" " + allSQLTypes[allSQLTypes.length - 1] + ")");
+ stmt.executeUpdate(createSQL.toString());
+ stmt.executeUpdate(createTestDataSQL.toString());
+
+ createSQL = new StringBuffer("insert into
AllDataTypesForTestingTable values(");
+ createTestDataSQL = new StringBuffer("insert into
AllDataTypesNewValuesData values(");
+ for (int type = 0; type < allSQLTypes.length - 1; type++)
+ {
+ createSQL.append(SQLData[type][0] + ",");
+ createTestDataSQL.append(SQLData[type][1] + ",");
+ }
+ createSQL.append("cast("+SQLData[allSQLTypes.length - 1][0]+"
as BLOB(1K)))");
+ createTestDataSQL.append("cast("+SQLData[allSQLTypes.length -
1][1]+" as BLOB(1K)))");
+ stmt.executeUpdate(createSQL.toString());
+ stmt.executeUpdate(createTestDataSQL.toString());
+
+ stmt.close();
+ }
+
+
+ static void teardown() throws SQLException {
+ Statement stmt = conn.createStatement();
+ stmt.executeUpdate("drop table t1");
+ stmt.executeUpdate("drop table t2");
+ stmt.executeUpdate("drop table t3");
+ stmt.executeUpdate("drop table tableWithConstraint");
+ stmt.executeUpdate("drop table tableWithPrimaryKey");
+ stmt.executeUpdate("drop table
deleteTriggerInsertIntoThisTable");
+ stmt.executeUpdate("drop table
updateTriggerInsertIntoThisTable");
+ stmt.executeUpdate("drop table table0WithTriggers");
+ stmt.executeUpdate("drop table table1WithTriggers");
+ stmt.executeUpdate("drop table table2WithTriggers");
+ stmt.executeUpdate("drop table selfReferencingT1");
+ stmt.executeUpdate("drop table selfReferencingT2");
+ conn.commit();
+ stmt.close();
+ }
+
+ public static void showScanStatistics(ResultSet rs, Connection conn)
+ {
+ Statement s = null;
+ ResultSet infors = null;
+
+
+ try {
+ rs.close(); // need to close to get statistics
+ s =conn.createStatement();
+ infors = s.executeQuery("values
SYSCS_UTIL.SYSCS_GET_RUNTIMESTATISTICS()");
+ JDBCDisplayUtil.setMaxDisplayWidth(2000);
+ JDBCDisplayUtil.DisplayResults(System.out,infors,conn);
+ infors.close();
+ }
+ catch (SQLException se)
+ {
+ System.out.print("FAIL:");
+ JDBCDisplayUtil.ShowSQLException(System.out,se);
+ }
+ }
+
+ static private void dumpSQLExceptions (SQLException se) {
+ System.out.println("FAIL -- unexpected exception: " +
se.toString());
+ while (se != null) {
+ System.out.print("SQLSTATE("+se.getSQLState()+"):");
+ se = se.getNextException();
+ }
+ }
+
+}
+
+=======
+/*
+
+ Derby - Class org.apache.derbyTesting.functionTests.lang.updatableResultSet
+
+ Copyright 2004 The Apache Software Foundation or its licensors, as
applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.functionTests.tests.lang;
+
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.Statement;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+
+import org.apache.derby.tools.ij;
+import org.apache.derby.tools.JDBCDisplayUtil;
+import org.apache.derbyTesting.functionTests.util.TestUtil;
import org.apache.derby.iapi.services.info.JVMInfo;
import java.math.BigDecimal;
@@ -2388,3 +4878,4 @@
}
+>>>>>>> .r161347
Index:
java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/updatableResultSet.out
===================================================================
---
java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/updatableResultSet.out
(revision 161347)
+++
java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/updatableResultSet.out
(working copy)
@@ -47,13 +47,88 @@
Got expected exception This method cannot be invoked while the cursor is on
the insert row or if the concurrency of this ResultSet object is
CONCUR_READ_ONLY.
Now attempting to send a updateRow on a sql with no FOR UPDATE clause.
SQL State : null
-Got expected exception Invalid operation: result set closed
+Got expected exception This method cannot be invoked while the cursor is on
the insert row or if the concurrency of this ResultSet object is
CONCUR_READ_ONLY.
Negative Test6 - request updatable resultset for sql with FOR READ ONLY clause
Make sure that we got CONCUR_READ_ONLY? true
+Jira issue Derby-159 : Warnings raised by Derby are not getting passed to the
Client in Network Server Mode
+Will see the warnings in embedded mode only
Now attempting to send a delete on a sql with FOR READ ONLY clause.
SQL State : null
Got expected exception This method cannot be invoked while the cursor is on
the insert row or if the concurrency of this ResultSet object is
CONCUR_READ_ONLY.
Now attempting to send a updateRow on a sql with FOR READ ONLY clause.
SQL State : null
Got expected exception This method cannot be invoked while the cursor is on
the insert row or if the concurrency of this ResultSet object is
CONCUR_READ_ONLY.
+Negative Test7 - attempt to deleteRow & updateRow on updatable resultset when
the resultset is not positioned on a row
+Make sure that we got CONCUR_UPDATABLE? true
+Now attempt a deleteRow without first doing next on the resultset.
+SQL State : XCL08
+Got expected exception Cursor 'SQL_CURSH200C7' is not on a row.
+Now attempt a updateRow without first doing next on the resultset.
+In embedded mode, updateRow will check if it is on a row or not even though no
changes have been made to the row using updateXXX
+In Network Server mode, if no updateXXX were issued before updateRow, then
updateRow is a no-op and doesn't check if it is on a row or not
+PASS!!! In Network Server mode, this updateRow is a no-op because no updateXXX
were issued before the updateRow
+ResultSet is positioned after the last row. attempt to deleteRow at this point
should fail!
+SQL State : null
+Got expected exception Invalid operation: result set closed
+ResultSet is positioned after the last row. attempt to updateRow at this point
should fail!
+SQL State : null
+Got expected exception Invalid operation: result set closed
+Negative Test8 - attempt deleteRow & updateRow on updatable resultset after
closing the resultset
+Make sure that we got CONCUR_UPDATABLE? true
+SQL State : null
+Got expected exception Invalid operation: result set closed
+SQL State : null
+Got expected exception Invalid operation: result set closed
+Negative Test9 - try updatable resultset on system table
+SQL State : 42Y90
+Got expected exception FOR UPDATE is not permitted on this type of statement.
+Negative Test10 - try updatable resultset on a view
+SQL State : 42Y90
+Got expected exception FOR UPDATE is not permitted on this type of statement.
+Negative Test11 - attempt to open updatable resultset when there is join in
the select query should fail
+SQL State : 42Y90
+Got expected exception FOR UPDATE is not permitted on this type of statement.
+Negative Test12 - With autocommit on, attempt to drop a table when there is an
open updatable resultset on it
+Opened an updatable resultset. Now trying to drop that table through another
Statement
+SQL State : X0X95
+Got expected exception Operation 'DROP TABLE' cannot be performed on object
'T1' because there is an open ResultSet dependent on that object.
+Since autocommit is on, the drop table exception resulted in a runtime
rollback causing updatable resultset object to close
+SQL State : 42X01
+Got expected exception Syntax error: Encountered "(" at line 1, column 19.
+SQL State : 24000
+Got expected exception Invalid cursor state - no current row.
+Negative Test13 - foreign key constraint failure will cause deleteRow to fail
+SQL State : 23503
+Got expected exception DELETE on table 'TABLEWITHPRIMARYKEY' caused a
violation of foreign key constraint 'FK' for key (1,1). The statement has been
rolled back.
+Since autocommit is on, the constraint exception resulted in a runtime
rollback causing updatable resultset object to close
+Jira entry Derby-160 : for Network Server because next should have failed
+FAIL!!! next should have failed because foreign key constraint failure
resulted in a runtime rollback
+Negative Test14 - foreign key constraint failure will cause updateRow to fail
+SQL State : 42X01
+Got expected exception Syntax error: Encountered "(" at line 1, column 36.
+Since autocommit is on, the constraint exception resulted in a runtime
rollback causing updatable resultset object to close
+Jira entry Derby-160 : for Network Server because next should have failed
+FAIL!!! next should have failed because foreign key constraint failure
resulted in a runtime rollback
+Negative Test15 - Can't call updateXXX methods on columns that do not
correspond to a column in the table
+SQL State : null
+Got expected exception Column not updatable
+Negative Test16 - Call updateXXX method on out of the range column
+There are only 2 columns in the select list and we are trying to send
updateXXX on column position 3
+SQL State : null
+Got expected exception Invalid argument: parameter index 3 is out of range.
+Positive Test1a - request updatable resultset for forward only type resultset
+requested TYPE_FORWARD_ONLY, CONCUR_UPDATABLE
+got TYPE_FORWARD_ONLY? true
+got CONCUR_UPDATABLE? true
+JDBC 2.0 updatable resultset apis on this ResultSet object will pass because
this is an updatable resultset
+column 1 on this row before deleteRow is 1
+column 2 on this row before deleteRow is aa
+Since after deleteRow(), in embedded mode, ResultSet is positioned before the
next row, getXXX will fail
+In Network Server mode, the ResultSet stays on the deleted row after deleteRow
and hence no error for getXXX
+column 1 on this deleted row is 0
+calling deleteRow again w/o first positioning the ResultSet on the next row
will fail
+SQL State : 24000
+Got expected exception Invalid cursor state - no current row.
+Position the ResultSet with next()
+Should be able to deletRow() on the current row now
Finished testing updateable resultsets
Index:
java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/resultset.out
===================================================================
---
java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/resultset.out
(revision 161347)
+++
java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/resultset.out
(working copy)
@@ -10,7 +10,7 @@
getColumnLabel(1): I
getColumnName(1): I
getTableName(1): T
-getSchemaName(1):
+getSchemaName(1): APP
getCatalogName(1):
getColumnType(1): 4
getPrecision(1): 10
@@ -28,7 +28,7 @@
getColumnLabel(2): S
getColumnName(2): S
getTableName(2): T
-getSchemaName(2):
+getSchemaName(2): APP
getCatalogName(2):
getColumnType(2): 5
getPrecision(2): 5
@@ -46,7 +46,7 @@
getColumnLabel(3): R
getColumnName(3): R
getTableName(3): T
-getSchemaName(3):
+getSchemaName(3): APP
getCatalogName(3):
getColumnType(3): 7
getPrecision(3): 7
@@ -64,7 +64,7 @@
getColumnLabel(4): D
getColumnName(4): D
getTableName(4): T
-getSchemaName(4):
+getSchemaName(4): APP
getCatalogName(4):
getColumnType(4): 8
getPrecision(4): 15
@@ -82,7 +82,7 @@
getColumnLabel(5): DT
getColumnName(5): DT
getTableName(5): T
-getSchemaName(5):
+getSchemaName(5): APP
getCatalogName(5):
getColumnType(5): 91
getPrecision(5): 10
@@ -100,7 +100,7 @@
getColumnLabel(6): T
getColumnName(6): T
getTableName(6): T
-getSchemaName(6):
+getSchemaName(6): APP
getCatalogName(6):
getColumnType(6): 92
getPrecision(6): 8
@@ -118,7 +118,7 @@
getColumnLabel(7): TS
getColumnName(7): TS
getTableName(7): T
-getSchemaName(7):
+getSchemaName(7): APP
getCatalogName(7):
getColumnType(7): 93
getPrecision(7): 26
@@ -136,7 +136,7 @@
getColumnLabel(8): C
getColumnName(8): C
getTableName(8): T
-getSchemaName(8):
+getSchemaName(8): APP
getCatalogName(8):
getColumnType(8): 1
getPrecision(8): 10
@@ -154,7 +154,7 @@
getColumnLabel(9): V
getColumnName(9): V
getTableName(9): T
-getSchemaName(9):
+getSchemaName(9): APP
getCatalogName(9):
getColumnType(9): 12
getPrecision(9): 40
@@ -172,7 +172,7 @@
getColumnLabel(10): DC
getColumnName(10): DC
getTableName(10): T
-getSchemaName(10):
+getSchemaName(10): APP
getCatalogName(10):
getColumnType(10): 3
getPrecision(10): 10
@@ -190,7 +190,7 @@
getColumnLabel(11): BI
getColumnName(11): BI
getTableName(11): T
-getSchemaName(11):
+getSchemaName(11): APP
getCatalogName(11):
getColumnType(11): -5
getPrecision(11): 19
@@ -208,7 +208,7 @@
getColumnLabel(12): CBD
getColumnName(12): CBD
getTableName(12): T
-getSchemaName(12):
+getSchemaName(12): APP
getCatalogName(12):
getColumnType(12): -2
getPrecision(12): 10
@@ -226,7 +226,7 @@
getColumnLabel(13): VBD
getColumnName(13): VBD
getTableName(13): T
-getSchemaName(13):
+getSchemaName(13): APP
getCatalogName(13):
getColumnType(13): -3
getPrecision(13): 10
@@ -244,7 +244,7 @@
getColumnLabel(14): LVBD
getColumnName(14): LVBD
getTableName(14): T
-getSchemaName(14):
+getSchemaName(14): APP
getCatalogName(14):
getColumnType(14): -4
getPrecision(14): 32700
@@ -262,7 +262,7 @@
getColumnLabel(15): CL
getColumnName(15): CL
getTableName(15): T
-getSchemaName(15):
+getSchemaName(15): APP
getCatalogName(15):
getColumnType(15): 2005
getPrecision(15): 2147483647
@@ -280,7 +280,7 @@
getColumnLabel(16): BL
getColumnName(16): BL
getTableName(16): T
-getSchemaName(16):
+getSchemaName(16): APP
getCatalogName(16):
getColumnType(16): 2004
getPrecision(16): 1073741824
Index:
java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/updatableResultSet.out
===================================================================
---
java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/updatableResultSet.out
(revision 161347)
+++
java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/updatableResultSet.out
(working copy)
@@ -47,13 +47,88 @@
Got expected exception This method cannot be invoked while the cursor is on
the insert row or if the concurrency of this ResultSet object is
CONCUR_READ_ONLY.
Now attempting to send a updateRow on a sql with no FOR UPDATE clause.
SQL State : null
-Got expected exception Invalid operation: result set closed
+Got expected exception This method cannot be invoked while the cursor is on
the insert row or if the concurrency of this ResultSet object is
CONCUR_READ_ONLY.
Negative Test6 - request updatable resultset for sql with FOR READ ONLY clause
Make sure that we got CONCUR_READ_ONLY? true
+Jira issue Derby-159 : Warnings raised by Derby are not getting passed to the
Client in Network Server Mode
+Will see the warnings in embedded mode only
Now attempting to send a delete on a sql with FOR READ ONLY clause.
SQL State : null
Got expected exception This method cannot be invoked while the cursor is on
the insert row or if the concurrency of this ResultSet object is
CONCUR_READ_ONLY.
Now attempting to send a updateRow on a sql with FOR READ ONLY clause.
SQL State : null
Got expected exception This method cannot be invoked while the cursor is on
the insert row or if the concurrency of this ResultSet object is
CONCUR_READ_ONLY.
+Negative Test7 - attempt to deleteRow & updateRow on updatable resultset when
the resultset is not positioned on a row
+Make sure that we got CONCUR_UPDATABLE? true
+Now attempt a deleteRow without first doing next on the resultset.
+SQL State : XCL08
+Got expected exception Cursor 'SQL_CURLH000C8' is not on a row.
+Now attempt a updateRow without first doing next on the resultset.
+In embedded mode, updateRow will check if it is on a row or not even though no
changes have been made to the row using updateXXX
+In Network Server mode, if no updateXXX were issued before updateRow, then
updateRow is a no-op and doesn't check if it is on a row or not
+PASS!!! In Network Server mode, this updateRow is a no-op because no updateXXX
were issued before the updateRow
+ResultSet is positioned after the last row. attempt to deleteRow at this point
should fail!
+SQL State : null
+Got expected exception Invalid operation: result set closed
+ResultSet is positioned after the last row. attempt to updateRow at this point
should fail!
+SQL State : null
+Got expected exception Invalid operation: result set closed
+Negative Test8 - attempt deleteRow & updateRow on updatable resultset after
closing the resultset
+Make sure that we got CONCUR_UPDATABLE? true
+SQL State : null
+Got expected exception Invalid operation: result set closed
+SQL State : null
+Got expected exception Invalid operation: result set closed
+Negative Test9 - try updatable resultset on system table
+SQL State : 42Y90
+Got expected exception FOR UPDATE is not permitted on this type of statement.
+Negative Test10 - try updatable resultset on a view
+SQL State : 42Y90
+Got expected exception FOR UPDATE is not permitted on this type of statement.
+Negative Test11 - attempt to open updatable resultset when there is join in
the select query should fail
+SQL State : 42Y90
+Got expected exception FOR UPDATE is not permitted on this type of statement.
+Negative Test12 - With autocommit on, attempt to drop a table when there is an
open updatable resultset on it
+Opened an updatable resultset. Now trying to drop that table through another
Statement
+SQL State : X0X95
+Got expected exception Operation 'DROP TABLE' cannot be performed on object
'T1' because there is an open ResultSet dependent on that object.
+Since autocommit is on, the drop table exception resulted in a runtime
rollback causing updatable resultset object to close
+SQL State : 24000
+Got expected exception Invalid cursor state - no current row.
+SQL State : 24000
+Got expected exception Invalid cursor state - no current row.
+Negative Test13 - foreign key constraint failure will cause deleteRow to fail
+SQL State : 23503
+Got expected exception DELETE on table 'TABLEWITHPRIMARYKEY' caused a
violation of foreign key constraint 'FK' for key (1,1). The statement has been
rolled back.
+Since autocommit is on, the constraint exception resulted in a runtime
rollback causing updatable resultset object to close
+Jira entry Derby-160 : for Network Server because next should have failed
+FAIL!!! next should have failed because foreign key constraint failure
resulted in a runtime rollback
+Negative Test14 - foreign key constraint failure will cause updateRow to fail
+SQL State : 23503
+Got expected exception UPDATE on table 'TABLEWITHPRIMARYKEY' caused a
violation of foreign key constraint 'FK' for key (1,1). The statement has been
rolled back.
+Since autocommit is on, the constraint exception resulted in a runtime
rollback causing updatable resultset object to close
+Jira entry Derby-160 : for Network Server because next should have failed
+FAIL!!! next should have failed because foreign key constraint failure
resulted in a runtime rollback
+Negative Test15 - Can't call updateXXX methods on columns that do not
correspond to a column in the table
+SQL State : null
+Got expected exception Column not updatable
+Negative Test16 - Call updateXXX method on out of the range column
+There are only 2 columns in the select list and we are trying to send
updateXXX on column position 3
+SQL State : null
+Got expected exception Invalid argument: parameter index 3 is out of range.
+Positive Test1a - request updatable resultset for forward only type resultset
+requested TYPE_FORWARD_ONLY, CONCUR_UPDATABLE
+got TYPE_FORWARD_ONLY? true
+got CONCUR_UPDATABLE? true
+JDBC 2.0 updatable resultset apis on this ResultSet object will pass because
this is an updatable resultset
+column 1 on this row before deleteRow is 1
+column 2 on this row before deleteRow is aa
+Since after deleteRow(), in embedded mode, ResultSet is positioned before the
next row, getXXX will fail
+In Network Server mode, the ResultSet stays on the deleted row after deleteRow
and hence no error for getXXX
+column 1 on this deleted row is 0
+calling deleteRow again w/o first positioning the ResultSet on the next row
will fail
+SQL State : 24000
+Got expected exception Invalid cursor state - no current row.
+Position the ResultSet with next()
+Should be able to deletRow() on the current row now
Finished testing updateable resultsets
Index:
java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/resultset.out
===================================================================
---
java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/resultset.out
(revision 161347)
+++
java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/resultset.out
(working copy)
@@ -10,7 +10,7 @@
getColumnLabel(1): I
getColumnName(1): I
getTableName(1): T
-getSchemaName(1):
+getSchemaName(1): APP
getCatalogName(1):
getColumnType(1): 4
getPrecision(1): 10
@@ -28,7 +28,7 @@
getColumnLabel(2): S
getColumnName(2): S
getTableName(2): T
-getSchemaName(2):
+getSchemaName(2): APP
getCatalogName(2):
getColumnType(2): 5
getPrecision(2): 5
@@ -46,7 +46,7 @@
getColumnLabel(3): R
getColumnName(3): R
getTableName(3): T
-getSchemaName(3):
+getSchemaName(3): APP
getCatalogName(3):
getColumnType(3): 7
getPrecision(3): 7
@@ -64,7 +64,7 @@
getColumnLabel(4): D
getColumnName(4): D
getTableName(4): T
-getSchemaName(4):
+getSchemaName(4): APP
getCatalogName(4):
getColumnType(4): 8
getPrecision(4): 15
@@ -82,7 +82,7 @@
getColumnLabel(5): DT
getColumnName(5): DT
getTableName(5): T
-getSchemaName(5):
+getSchemaName(5): APP
getCatalogName(5):
getColumnType(5): 91
getPrecision(5): 10
@@ -100,7 +100,7 @@
getColumnLabel(6): T
getColumnName(6): T
getTableName(6): T
-getSchemaName(6):
+getSchemaName(6): APP
getCatalogName(6):
getColumnType(6): 92
getPrecision(6): 8
@@ -118,7 +118,7 @@
getColumnLabel(7): TS
getColumnName(7): TS
getTableName(7): T
-getSchemaName(7):
+getSchemaName(7): APP
getCatalogName(7):
getColumnType(7): 93
getPrecision(7): 26
@@ -136,7 +136,7 @@
getColumnLabel(8): C
getColumnName(8): C
getTableName(8): T
-getSchemaName(8):
+getSchemaName(8): APP
getCatalogName(8):
getColumnType(8): 1
getPrecision(8): 10
@@ -154,7 +154,7 @@
getColumnLabel(9): V
getColumnName(9): V
getTableName(9): T
-getSchemaName(9):
+getSchemaName(9): APP
getCatalogName(9):
getColumnType(9): 12
getPrecision(9): 40
@@ -172,7 +172,7 @@
getColumnLabel(10): DC
getColumnName(10): DC
getTableName(10): T
-getSchemaName(10):
+getSchemaName(10): APP
getCatalogName(10):
getColumnType(10): 3
getPrecision(10): 10
@@ -190,7 +190,7 @@
getColumnLabel(11): BI
getColumnName(11): BI
getTableName(11): T
-getSchemaName(11):
+getSchemaName(11): APP
getCatalogName(11):
getColumnType(11): -5
getPrecision(11): 19
@@ -208,7 +208,7 @@
getColumnLabel(12): CBD
getColumnName(12): CBD
getTableName(12): T
-getSchemaName(12):
+getSchemaName(12): APP
getCatalogName(12):
getColumnType(12): -2
getPrecision(12): 10
@@ -226,7 +226,7 @@
getColumnLabel(13): VBD
getColumnName(13): VBD
getTableName(13): T
-getSchemaName(13):
+getSchemaName(13): APP
getCatalogName(13):
getColumnType(13): -3
getPrecision(13): 10
@@ -244,7 +244,7 @@
getColumnLabel(14): LVBD
getColumnName(14): LVBD
getTableName(14): T
-getSchemaName(14):
+getSchemaName(14): APP
getCatalogName(14):
getColumnType(14): -4
getPrecision(14): 32700
@@ -262,7 +262,7 @@
getColumnLabel(15): CL
getColumnName(15): CL
getTableName(15): T
-getSchemaName(15):
+getSchemaName(15): APP
getCatalogName(15):
getColumnType(15): 2005
getPrecision(15): 2147483647
@@ -280,7 +280,7 @@
getColumnLabel(16): BL
getColumnName(16): BL
getTableName(16): T
-getSchemaName(16):
+getSchemaName(16): APP
getCatalogName(16):
getColumnType(16): 2004
getPrecision(16): 1073741824
Index:
java/testing/org/apache/derbyTesting/functionTests/master/updatableResultSet.out
===================================================================
---
java/testing/org/apache/derbyTesting/functionTests/master/updatableResultSet.out
(revision 161347)
+++
java/testing/org/apache/derbyTesting/functionTests/master/updatableResultSet.out
(working copy)
@@ -51,6 +51,8 @@
Got expected exception 'updateRow' not allowed because the ResultSet is not an
updatable ResultSet.
Negative Test6 - request updatable resultset for sql with FOR READ ONLY clause
Make sure that we got CONCUR_READ_ONLY? true
+Jira issue Derby-159 : Warnings raised by Derby are not getting passed to the
Client in Network Server Mode
+Will see the warnings in embedded mode only
Expected warnings on resultset = java.sql.SQLWarning: ResultSet not updatable.
Query does not qualify to generate an updatable ResultSet.
Now attempting to send a delete on a sql with FOR READ ONLY clause.
SQL State : XJ083
@@ -64,6 +66,8 @@
SQL State : 24000
Got expected exception Invalid cursor state - no current row.
Now attempt a updateRow without first doing next on the resultset.
+In embedded mode, updateRow will check if it is on a row or not even though no
changes have been made to the row using updateXXX
+In Network Server mode, if no updateXXX were issued before updateRow, then
updateRow is a no-op and doesn't check if it is on a row or not
SQL State : 24000
Got expected exception Invalid cursor state - no current row.
ResultSet is positioned after the last row. attempt to deleteRow at this point
should fail!
@@ -122,7 +126,8 @@
JDBC 2.0 updatable resultset apis on this ResultSet object will pass because
this is an updatable resultset
column 1 on this row before deleteRow is 1
column 2 on this row before deleteRow is aa
-Since after deleteRow(), ResultSet is positioned before the next row, getXXX
will fail
+Since after deleteRow(), in embedded mode, ResultSet is positioned before the
next row, getXXX will fail
+In Network Server mode, the ResultSet stays on the deleted row after deleteRow
and hence no error for getXXX
SQL State : 24000
Got expected exception Invalid cursor state - no current row.
calling deleteRow again w/o first positioning the ResultSet on the next row
will fail
@@ -135,7 +140,8 @@
column 1 on this row after updateInt is 234
column 2 on this row before updateString is aa
now updateRow on the row
-Since after updateRow(), ResultSet is positioned before the next row, getXXX
will fail
+Since after updateRow(), in embedded mode, ResultSet is positioned before the
next row, getXXX will fail
+In Network Server mode, the ResultSet stays on the updated row after updateRow
and hence no error for getXXX
SQL State : 24000
Got expected exception Invalid cursor state - no current row.
calling updateRow again w/o first positioning the ResultSet on the next row
will fail
@@ -269,17 +275,37 @@
Positive Test9c - try to updateXXX on a readonly column. Should get error
SQL State : 42X31
Got expected exception Column 'C2' is not in FOR UPDATE list of cursor
'SQLCUR15'.
+attempt to get an updatable resultset using correlation name for an readonly
column. It should work
+The sql is SELECT c1, c2 as col2 FROM t1 abcde FOR UPDATE of c1
Table t1 after updateRow has following rows
C1,C2
-- --
+ {11,aa }
+ {2,bb }
+ {3,cc }
+Positive Test9c - try to updateXXX on a readonly column. Should get error
+SQL State : 42X31
+Got expected exception Column 'C2' is not in FOR UPDATE list of cursor
'SQLCUR17'.
+Table t1 has following rows
+ C1,C2
+ -- --
{1,aa }
{2,bb }
{3,cc }
+Positive Test9d - try to updateXXX on a readonly column with correlation name.
Should get error
+SQL State : 42X31
+Got expected exception Column 'COL2' is not in FOR UPDATE list of cursor
'SQLCUR18'.
+Table t1 has following rows
+ C1,C2
+ -- --
+ {1,aa }
+ {2,bb }
+ {3,cc }
Positive Test10 - 2 updatable resultsets going against the same table, will
they conflict?
delete using first resultset
attempt to send deleteRow on the same row through a different resultset should
throw an exception
SQL State : XCL08
-Got expected exception Cursor 'SQLCUR17' is not on a row.
+Got expected exception Cursor 'SQLCUR20' is not on a row.
Move to next row in the 2nd resultset and then delete using the second
resultset
Positive Test11 - setting the fetch size to > 1 will be ignored by updatable
resultset. Same as updatable cursors
Notice the Fetch Size in run time statistics output.
@@ -563,7 +589,9 @@
Got expected exception : 'updateBinaryStream' not allowed because the
ResultSet is not an updatable ResultSet.
Test updateClob on a readonly resultset
Using column position as first parameter to updateClob
+ Got expected exception : 'updateClob' not allowed because the ResultSet is
not an updatable ResultSet.
Using column name as first parameter to updateClob
+ Got expected exception : 'updateClob' not allowed because the ResultSet is
not an updatable ResultSet.
Test updateDate on a readonly resultset
Using column position as first parameter to updateDate
Got expected exception : 'updateDate' not allowed because the ResultSet is
not an updatable ResultSet.
@@ -581,7 +609,9 @@
Got expected exception : 'updateTimestamp' not allowed because the ResultSet
is not an updatable ResultSet.
Test updateBlob on a readonly resultset
Using column position as first parameter to updateBlob
+ Got expected exception : 'updateBlob' not allowed because the ResultSet is
not an updatable ResultSet.
Using column name as first parameter to updateBlob
+ Got expected exception : 'updateBlob' not allowed because the ResultSet is
not an updatable ResultSet.
Test updateBoolean on a readonly resultset
Using column position as first parameter to updateBoolean
Got expected exception : 'updateBoolean' not allowed because the ResultSet
is not an updatable ResultSet.
@@ -594,10 +624,14 @@
Got expected exception : 'updateNull' not allowed because the ResultSet is
not an updatable ResultSet.
Test updateArray on a readonly resultset
Using column position as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Test updateRef on a readonly resultset
Using column position as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Positive Test21 - Test all updateXXX(excluding updateObject) methods on all
the supported sql datatypes
Next datatype to test is SMALLINT
Testing updateShort on SQL type SMALLINT
@@ -646,7 +680,9 @@
Got expected exception : An attempt was made to get a data value of type
'SMALLINT' from a data value of type 'java.io.InputStream'.
Testing updateClob on SQL type SMALLINT
Using column position as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'SMALLINT' from a data value of type 'java.sql.Clob'.
Using column name as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'SMALLINT' from a data value of type 'java.sql.Clob'.
Testing updateDate on SQL type SMALLINT
Using column position as first parameter to updateDate
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'SMALLINT'.
@@ -664,7 +700,9 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'SMALLINT'.
Testing updateBlob on SQL type SMALLINT
Using column position as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'SMALLINT' from a data value of type 'java.sql.Blob'.
Using column name as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'SMALLINT' from a data value of type 'java.sql.Blob'.
Testing updateBoolean on SQL type SMALLINT
Using column position as first parameter to updateBoolean
Using column name as first parameter to updateBoolean
@@ -673,10 +711,14 @@
Using column name as first parameter to updateNull
Testing updateArray on SQL type SMALLINT
Using column position as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Testing updateRef on SQL type SMALLINT
Using column position as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Next datatype to test is INTEGER
Testing updateShort on SQL type INTEGER
Using column position as first parameter to updateShort
@@ -724,7 +766,9 @@
Got expected exception : An attempt was made to get a data value of type
'INTEGER' from a data value of type 'java.io.InputStream'.
Testing updateClob on SQL type INTEGER
Using column position as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'INTEGER' from a data value of type 'java.sql.Clob'.
Using column name as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'INTEGER' from a data value of type 'java.sql.Clob'.
Testing updateDate on SQL type INTEGER
Using column position as first parameter to updateDate
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'INTEGER'.
@@ -742,7 +786,9 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'INTEGER'.
Testing updateBlob on SQL type INTEGER
Using column position as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'INTEGER' from a data value of type 'java.sql.Blob'.
Using column name as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'INTEGER' from a data value of type 'java.sql.Blob'.
Testing updateBoolean on SQL type INTEGER
Using column position as first parameter to updateBoolean
Using column name as first parameter to updateBoolean
@@ -751,10 +797,14 @@
Using column name as first parameter to updateNull
Testing updateArray on SQL type INTEGER
Using column position as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Testing updateRef on SQL type INTEGER
Using column position as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Next datatype to test is BIGINT
Testing updateShort on SQL type BIGINT
Using column position as first parameter to updateShort
@@ -802,7 +852,9 @@
Got expected exception : An attempt was made to get a data value of type
'BIGINT' from a data value of type 'java.io.InputStream'.
Testing updateClob on SQL type BIGINT
Using column position as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'BIGINT' from a data value of type 'java.sql.Clob'.
Using column name as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'BIGINT' from a data value of type 'java.sql.Clob'.
Testing updateDate on SQL type BIGINT
Using column position as first parameter to updateDate
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'BIGINT'.
@@ -820,7 +872,9 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'BIGINT'.
Testing updateBlob on SQL type BIGINT
Using column position as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'BIGINT' from a data value of type 'java.sql.Blob'.
Using column name as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'BIGINT' from a data value of type 'java.sql.Blob'.
Testing updateBoolean on SQL type BIGINT
Using column position as first parameter to updateBoolean
Using column name as first parameter to updateBoolean
@@ -829,10 +883,14 @@
Using column name as first parameter to updateNull
Testing updateArray on SQL type BIGINT
Using column position as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Testing updateRef on SQL type BIGINT
Using column position as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Next datatype to test is DECIMAL(10,5)
Testing updateShort on SQL type DECIMAL(10,5)
Using column position as first parameter to updateShort
@@ -880,7 +938,9 @@
Got expected exception : An attempt was made to get a data value of type
'DECIMAL' from a data value of type 'java.io.InputStream'.
Testing updateClob on SQL type DECIMAL(10,5)
Using column position as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'DECIMAL' from a data value of type 'java.sql.Clob'.
Using column name as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'DECIMAL' from a data value of type 'java.sql.Clob'.
Testing updateDate on SQL type DECIMAL(10,5)
Using column position as first parameter to updateDate
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'DECIMAL'.
@@ -898,7 +958,9 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'DECIMAL'.
Testing updateBlob on SQL type DECIMAL(10,5)
Using column position as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'DECIMAL' from a data value of type 'java.sql.Blob'.
Using column name as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'DECIMAL' from a data value of type 'java.sql.Blob'.
Testing updateBoolean on SQL type DECIMAL(10,5)
Using column position as first parameter to updateBoolean
Using column name as first parameter to updateBoolean
@@ -907,10 +969,14 @@
Using column name as first parameter to updateNull
Testing updateArray on SQL type DECIMAL(10,5)
Using column position as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Testing updateRef on SQL type DECIMAL(10,5)
Using column position as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Next datatype to test is REAL
Testing updateShort on SQL type REAL
Using column position as first parameter to updateShort
@@ -958,7 +1024,9 @@
Got expected exception : An attempt was made to get a data value of type
'REAL' from a data value of type 'java.io.InputStream'.
Testing updateClob on SQL type REAL
Using column position as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'REAL' from a data value of type 'java.sql.Clob'.
Using column name as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'REAL' from a data value of type 'java.sql.Clob'.
Testing updateDate on SQL type REAL
Using column position as first parameter to updateDate
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'REAL'.
@@ -976,7 +1044,9 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'REAL'.
Testing updateBlob on SQL type REAL
Using column position as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'REAL' from a data value of type 'java.sql.Blob'.
Using column name as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'REAL' from a data value of type 'java.sql.Blob'.
Testing updateBoolean on SQL type REAL
Using column position as first parameter to updateBoolean
Using column name as first parameter to updateBoolean
@@ -985,10 +1055,14 @@
Using column name as first parameter to updateNull
Testing updateArray on SQL type REAL
Using column position as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Testing updateRef on SQL type REAL
Using column position as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Next datatype to test is DOUBLE
Testing updateShort on SQL type DOUBLE
Using column position as first parameter to updateShort
@@ -1036,7 +1110,9 @@
Got expected exception : An attempt was made to get a data value of type
'DOUBLE' from a data value of type 'java.io.InputStream'.
Testing updateClob on SQL type DOUBLE
Using column position as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'DOUBLE' from a data value of type 'java.sql.Clob'.
Using column name as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'DOUBLE' from a data value of type 'java.sql.Clob'.
Testing updateDate on SQL type DOUBLE
Using column position as first parameter to updateDate
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'DOUBLE'.
@@ -1054,7 +1130,9 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'DOUBLE'.
Testing updateBlob on SQL type DOUBLE
Using column position as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'DOUBLE' from a data value of type 'java.sql.Blob'.
Using column name as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'DOUBLE' from a data value of type 'java.sql.Blob'.
Testing updateBoolean on SQL type DOUBLE
Using column position as first parameter to updateBoolean
Using column name as first parameter to updateBoolean
@@ -1063,10 +1141,14 @@
Using column name as first parameter to updateNull
Testing updateArray on SQL type DOUBLE
Using column position as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Testing updateRef on SQL type DOUBLE
Using column position as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Next datatype to test is CHAR(60)
Testing updateShort on SQL type CHAR(60)
Using column position as first parameter to updateShort
@@ -1108,7 +1190,9 @@
Got expected exception : An attempt was made to get a data value of type
'CHAR' from a data value of type 'java.io.InputStream'.
Testing updateClob on SQL type CHAR(60)
Using column position as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'CHAR' from a data value of type 'java.sql.Clob'.
Using column name as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'CHAR' from a data value of type 'java.sql.Clob'.
Testing updateDate on SQL type CHAR(60)
Using column position as first parameter to updateDate
Using column name as first parameter to updateDate
@@ -1120,7 +1204,9 @@
Using column name as first parameter to updateTimestamp
Testing updateBlob on SQL type CHAR(60)
Using column position as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'CHAR' from a data value of type 'java.sql.Blob'.
Using column name as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'CHAR' from a data value of type 'java.sql.Blob'.
Testing updateBoolean on SQL type CHAR(60)
Using column position as first parameter to updateBoolean
Using column name as first parameter to updateBoolean
@@ -1129,10 +1215,14 @@
Using column name as first parameter to updateNull
Testing updateArray on SQL type CHAR(60)
Using column position as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Testing updateRef on SQL type CHAR(60)
Using column position as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Next datatype to test is VARCHAR(60)
Testing updateShort on SQL type VARCHAR(60)
Using column position as first parameter to updateShort
@@ -1174,7 +1264,9 @@
Got expected exception : An attempt was made to get a data value of type
'VARCHAR' from a data value of type 'java.io.InputStream'.
Testing updateClob on SQL type VARCHAR(60)
Using column position as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'VARCHAR' from a data value of type 'java.sql.Clob'.
Using column name as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'VARCHAR' from a data value of type 'java.sql.Clob'.
Testing updateDate on SQL type VARCHAR(60)
Using column position as first parameter to updateDate
Using column name as first parameter to updateDate
@@ -1186,7 +1278,9 @@
Using column name as first parameter to updateTimestamp
Testing updateBlob on SQL type VARCHAR(60)
Using column position as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'VARCHAR' from a data value of type 'java.sql.Blob'.
Using column name as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'VARCHAR' from a data value of type 'java.sql.Blob'.
Testing updateBoolean on SQL type VARCHAR(60)
Using column position as first parameter to updateBoolean
Using column name as first parameter to updateBoolean
@@ -1195,10 +1289,14 @@
Using column name as first parameter to updateNull
Testing updateArray on SQL type VARCHAR(60)
Using column position as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Testing updateRef on SQL type VARCHAR(60)
Using column position as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Next datatype to test is LONG VARCHAR
Testing updateShort on SQL type LONG VARCHAR
Using column position as first parameter to updateShort
@@ -1240,7 +1338,9 @@
Got expected exception : An attempt was made to get a data value of type
'LONG VARCHAR' from a data value of type 'java.io.InputStream'.
Testing updateClob on SQL type LONG VARCHAR
Using column position as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'LONG VARCHAR' from a data value of type 'java.sql.Clob'.
Using column name as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'LONG VARCHAR' from a data value of type 'java.sql.Clob'.
Testing updateDate on SQL type LONG VARCHAR
Using column position as first parameter to updateDate
Using column name as first parameter to updateDate
@@ -1252,7 +1352,9 @@
Using column name as first parameter to updateTimestamp
Testing updateBlob on SQL type LONG VARCHAR
Using column position as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'LONG VARCHAR' from a data value of type 'java.sql.Blob'.
Using column name as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'LONG VARCHAR' from a data value of type 'java.sql.Blob'.
Testing updateBoolean on SQL type LONG VARCHAR
Using column position as first parameter to updateBoolean
Using column name as first parameter to updateBoolean
@@ -1261,10 +1363,14 @@
Using column name as first parameter to updateNull
Testing updateArray on SQL type LONG VARCHAR
Using column position as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Testing updateRef on SQL type LONG VARCHAR
Using column position as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Next datatype to test is CHAR(2) FOR BIT DATA
Testing updateShort on SQL type CHAR(2) FOR BIT DATA
Using column position as first parameter to updateShort
@@ -1324,7 +1430,9 @@
Using column name as first parameter to updateBinaryStream
Testing updateClob on SQL type CHAR(2) FOR BIT DATA
Using column position as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'CHAR () FOR BIT DATA' from a data value of type 'java.sql.Clob'.
Using column name as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'CHAR () FOR BIT DATA' from a data value of type 'java.sql.Clob'.
Testing updateDate on SQL type CHAR(2) FOR BIT DATA
Using column position as first parameter to updateDate
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'CHAR () FOR BIT DATA'.
@@ -1342,7 +1450,9 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'CHAR () FOR BIT DATA'.
Testing updateBlob on SQL type CHAR(2) FOR BIT DATA
Using column position as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'CHAR () FOR BIT DATA' from a data value of type 'java.sql.Blob'.
Using column name as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'CHAR () FOR BIT DATA' from a data value of type 'java.sql.Blob'.
Testing updateBoolean on SQL type CHAR(2) FOR BIT DATA
Using column position as first parameter to updateBoolean
Got expected exception : An attempt was made to put a data value of type
'boolean' into a data value of type 'CHAR () FOR BIT DATA'.
@@ -1353,10 +1463,14 @@
Using column name as first parameter to updateNull
Testing updateArray on SQL type CHAR(2) FOR BIT DATA
Using column position as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Testing updateRef on SQL type CHAR(2) FOR BIT DATA
Using column position as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Next datatype to test is VARCHAR(2) FOR BIT DATA
Testing updateShort on SQL type VARCHAR(2) FOR BIT DATA
Using column position as first parameter to updateShort
@@ -1416,7 +1530,9 @@
Using column name as first parameter to updateBinaryStream
Testing updateClob on SQL type VARCHAR(2) FOR BIT DATA
Using column position as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'VARCHAR () FOR BIT DATA' from a data value of type 'java.sql.Clob'.
Using column name as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'VARCHAR () FOR BIT DATA' from a data value of type 'java.sql.Clob'.
Testing updateDate on SQL type VARCHAR(2) FOR BIT DATA
Using column position as first parameter to updateDate
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'VARCHAR () FOR BIT DATA'.
@@ -1434,7 +1550,9 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'VARCHAR () FOR BIT DATA'.
Testing updateBlob on SQL type VARCHAR(2) FOR BIT DATA
Using column position as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'VARCHAR () FOR BIT DATA' from a data value of type 'java.sql.Blob'.
Using column name as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'VARCHAR () FOR BIT DATA' from a data value of type 'java.sql.Blob'.
Testing updateBoolean on SQL type VARCHAR(2) FOR BIT DATA
Using column position as first parameter to updateBoolean
Got expected exception : An attempt was made to put a data value of type
'boolean' into a data value of type 'VARCHAR () FOR BIT DATA'.
@@ -1445,10 +1563,14 @@
Using column name as first parameter to updateNull
Testing updateArray on SQL type VARCHAR(2) FOR BIT DATA
Using column position as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Testing updateRef on SQL type VARCHAR(2) FOR BIT DATA
Using column position as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Next datatype to test is LONG VARCHAR FOR BIT DATA
Testing updateShort on SQL type LONG VARCHAR FOR BIT DATA
Using column position as first parameter to updateShort
@@ -1508,7 +1630,9 @@
Using column name as first parameter to updateBinaryStream
Testing updateClob on SQL type LONG VARCHAR FOR BIT DATA
Using column position as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'LONG VARCHAR FOR BIT DATA' from a data value of type 'java.sql.Clob'.
Using column name as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'LONG VARCHAR FOR BIT DATA' from a data value of type 'java.sql.Clob'.
Testing updateDate on SQL type LONG VARCHAR FOR BIT DATA
Using column position as first parameter to updateDate
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'LONG VARCHAR FOR BIT DATA'.
@@ -1526,7 +1650,9 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'LONG VARCHAR FOR BIT DATA'.
Testing updateBlob on SQL type LONG VARCHAR FOR BIT DATA
Using column position as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'LONG VARCHAR FOR BIT DATA' from a data value of type 'java.sql.Blob'.
Using column name as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'LONG VARCHAR FOR BIT DATA' from a data value of type 'java.sql.Blob'.
Testing updateBoolean on SQL type LONG VARCHAR FOR BIT DATA
Using column position as first parameter to updateBoolean
Got expected exception : An attempt was made to put a data value of type
'boolean' into a data value of type 'LONG VARCHAR FOR BIT DATA'.
@@ -1537,10 +1663,14 @@
Using column name as first parameter to updateNull
Testing updateArray on SQL type LONG VARCHAR FOR BIT DATA
Using column position as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Testing updateRef on SQL type LONG VARCHAR FOR BIT DATA
Using column position as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Next datatype to test is CLOB(1k)
Testing updateShort on SQL type CLOB(1k)
Using column position as first parameter to updateShort
@@ -1616,7 +1746,9 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'CLOB'.
Testing updateBlob on SQL type CLOB(1k)
Using column position as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'CLOB' from a data value of type 'java.sql.Blob'.
Using column name as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'CLOB' from a data value of type 'java.sql.Blob'.
Testing updateBoolean on SQL type CLOB(1k)
Using column position as first parameter to updateBoolean
Got expected exception : An attempt was made to put a data value of type
'boolean' into a data value of type 'CLOB'.
@@ -1627,10 +1759,14 @@
Using column name as first parameter to updateNull
Testing updateArray on SQL type CLOB(1k)
Using column position as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Testing updateRef on SQL type CLOB(1k)
Using column position as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Next datatype to test is DATE
Testing updateShort on SQL type DATE
Using column position as first parameter to updateShort
@@ -1694,7 +1830,9 @@
Got expected exception : An attempt was made to get a data value of type
'DATE' from a data value of type 'java.io.InputStream'.
Testing updateClob on SQL type DATE
Using column position as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'DATE' from a data value of type 'java.sql.Clob'.
Using column name as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'DATE' from a data value of type 'java.sql.Clob'.
Testing updateDate on SQL type DATE
Using column position as first parameter to updateDate
Using column name as first parameter to updateDate
@@ -1708,7 +1846,9 @@
Using column name as first parameter to updateTimestamp
Testing updateBlob on SQL type DATE
Using column position as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'DATE' from a data value of type 'java.sql.Blob'.
Using column name as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'DATE' from a data value of type 'java.sql.Blob'.
Testing updateBoolean on SQL type DATE
Using column position as first parameter to updateBoolean
Got expected exception : An attempt was made to put a data value of type
'boolean' into a data value of type 'DATE'.
@@ -1719,10 +1859,14 @@
Using column name as first parameter to updateNull
Testing updateArray on SQL type DATE
Using column position as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Testing updateRef on SQL type DATE
Using column position as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Next datatype to test is TIME
Testing updateShort on SQL type TIME
Using column position as first parameter to updateShort
@@ -1786,7 +1930,9 @@
Got expected exception : An attempt was made to get a data value of type
'TIME' from a data value of type 'java.io.InputStream'.
Testing updateClob on SQL type TIME
Using column position as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'TIME' from a data value of type 'java.sql.Clob'.
Using column name as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'TIME' from a data value of type 'java.sql.Clob'.
Testing updateDate on SQL type TIME
Using column position as first parameter to updateDate
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'TIME'.
@@ -1800,7 +1946,9 @@
Using column name as first parameter to updateTimestamp
Testing updateBlob on SQL type TIME
Using column position as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'TIME' from a data value of type 'java.sql.Blob'.
Using column name as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'TIME' from a data value of type 'java.sql.Blob'.
Testing updateBoolean on SQL type TIME
Using column position as first parameter to updateBoolean
Got expected exception : An attempt was made to put a data value of type
'boolean' into a data value of type 'TIME'.
@@ -1811,10 +1959,14 @@
Using column name as first parameter to updateNull
Testing updateArray on SQL type TIME
Using column position as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Testing updateRef on SQL type TIME
Using column position as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Next datatype to test is TIMESTAMP
Testing updateShort on SQL type TIMESTAMP
Using column position as first parameter to updateShort
@@ -1878,7 +2030,9 @@
Got expected exception : An attempt was made to get a data value of type
'TIMESTAMP' from a data value of type 'java.io.InputStream'.
Testing updateClob on SQL type TIMESTAMP
Using column position as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'TIMESTAMP' from a data value of type 'java.sql.Clob'.
Using column name as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'TIMESTAMP' from a data value of type 'java.sql.Clob'.
Testing updateDate on SQL type TIMESTAMP
Using column position as first parameter to updateDate
Using column name as first parameter to updateDate
@@ -1890,7 +2044,9 @@
Using column name as first parameter to updateTimestamp
Testing updateBlob on SQL type TIMESTAMP
Using column position as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'TIMESTAMP' from a data value of type 'java.sql.Blob'.
Using column name as first parameter to updateBlob
+ Got expected exception : An attempt was made to get a data value of type
'TIMESTAMP' from a data value of type 'java.sql.Blob'.
Testing updateBoolean on SQL type TIMESTAMP
Using column position as first parameter to updateBoolean
Got expected exception : An attempt was made to put a data value of type
'boolean' into a data value of type 'TIMESTAMP'.
@@ -1901,10 +2057,14 @@
Using column name as first parameter to updateNull
Testing updateArray on SQL type TIMESTAMP
Using column position as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Testing updateRef on SQL type TIMESTAMP
Using column position as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Next datatype to test is BLOB(1k)
Testing updateShort on SQL type BLOB(1k)
Using column position as first parameter to updateShort
@@ -1964,7 +2124,9 @@
Using column name as first parameter to updateBinaryStream
Testing updateClob on SQL type BLOB(1k)
Using column position as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'BLOB' from a data value of type 'java.sql.Clob'.
Using column name as first parameter to updateClob
+ Got expected exception : An attempt was made to get a data value of type
'BLOB' from a data value of type 'java.sql.Clob'.
Testing updateDate on SQL type BLOB(1k)
Using column position as first parameter to updateDate
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'BLOB'.
@@ -1993,10 +2155,14 @@
Using column name as first parameter to updateNull
Testing updateArray on SQL type BLOB(1k)
Using column position as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateArray
+ Got expected exception : Feature not implemented: no details.
Testing updateRef on SQL type BLOB(1k)
Using column position as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Using column name as first parameter to updateRef
+ Got expected exception : Feature not implemented: no details.
Positive Test22 - Test updateObject method
Next datatype to test is SMALLINT
updateObject with column position & Short object as parameters
@@ -2017,6 +2183,10 @@
Got expected exception : An attempt was made to put a data value of type
'byte[]' into a data value of type 'SMALLINT'.
updateObject with column name & bytes[] array as parameters
Got expected exception : An attempt was made to put a data value of type
'byte[]' into a data value of type 'SMALLINT'.
+ updateObject with column position & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'SMALLINT' from a data value of type 'java.sql.Clob'.
+ updateObject with column name & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'SMALLINT' from a data value of type 'java.sql.Clob'.
updateObject with column position & Date object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'SMALLINT'.
updateObject with column name & Date object as parameters
@@ -2029,6 +2199,10 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'SMALLINT'.
updateObject with column name & TimeStamp object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'SMALLINT'.
+ updateObject with column position & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'SMALLINT' from a data value of type 'java.sql.Blob'.
+ updateObject with column name & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'SMALLINT' from a data value of type 'java.sql.Blob'.
updateObject with column position & Boolean object as parameters
updateObject with column name & Boolean object as parameters
updateObject with column position & null as parameters
@@ -2052,6 +2226,10 @@
Got expected exception : An attempt was made to put a data value of type
'byte[]' into a data value of type 'INTEGER'.
updateObject with column name & bytes[] array as parameters
Got expected exception : An attempt was made to put a data value of type
'byte[]' into a data value of type 'INTEGER'.
+ updateObject with column position & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'INTEGER' from a data value of type 'java.sql.Clob'.
+ updateObject with column name & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'INTEGER' from a data value of type 'java.sql.Clob'.
updateObject with column position & Date object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'INTEGER'.
updateObject with column name & Date object as parameters
@@ -2064,6 +2242,10 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'INTEGER'.
updateObject with column name & TimeStamp object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'INTEGER'.
+ updateObject with column position & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'INTEGER' from a data value of type 'java.sql.Blob'.
+ updateObject with column name & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'INTEGER' from a data value of type 'java.sql.Blob'.
updateObject with column position & Boolean object as parameters
updateObject with column name & Boolean object as parameters
updateObject with column position & null as parameters
@@ -2087,6 +2269,10 @@
Got expected exception : An attempt was made to put a data value of type
'byte[]' into a data value of type 'BIGINT'.
updateObject with column name & bytes[] array as parameters
Got expected exception : An attempt was made to put a data value of type
'byte[]' into a data value of type 'BIGINT'.
+ updateObject with column position & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'BIGINT' from a data value of type 'java.sql.Clob'.
+ updateObject with column name & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'BIGINT' from a data value of type 'java.sql.Clob'.
updateObject with column position & Date object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'BIGINT'.
updateObject with column name & Date object as parameters
@@ -2099,6 +2285,10 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'BIGINT'.
updateObject with column name & TimeStamp object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'BIGINT'.
+ updateObject with column position & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'BIGINT' from a data value of type 'java.sql.Blob'.
+ updateObject with column name & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'BIGINT' from a data value of type 'java.sql.Blob'.
updateObject with column position & Boolean object as parameters
updateObject with column name & Boolean object as parameters
updateObject with column position & null as parameters
@@ -2122,6 +2312,10 @@
Got expected exception : An attempt was made to put a data value of type
'byte[]' into a data value of type 'DECIMAL'.
updateObject with column name & bytes[] array as parameters
Got expected exception : An attempt was made to put a data value of type
'byte[]' into a data value of type 'DECIMAL'.
+ updateObject with column position & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'DECIMAL' from a data value of type 'java.sql.Clob'.
+ updateObject with column name & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'DECIMAL' from a data value of type 'java.sql.Clob'.
updateObject with column position & Date object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'DECIMAL'.
updateObject with column name & Date object as parameters
@@ -2134,6 +2328,10 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'DECIMAL'.
updateObject with column name & TimeStamp object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'DECIMAL'.
+ updateObject with column position & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'DECIMAL' from a data value of type 'java.sql.Blob'.
+ updateObject with column name & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'DECIMAL' from a data value of type 'java.sql.Blob'.
updateObject with column position & Boolean object as parameters
updateObject with column name & Boolean object as parameters
updateObject with column position & null as parameters
@@ -2157,6 +2355,10 @@
Got expected exception : An attempt was made to put a data value of type
'byte[]' into a data value of type 'REAL'.
updateObject with column name & bytes[] array as parameters
Got expected exception : An attempt was made to put a data value of type
'byte[]' into a data value of type 'REAL'.
+ updateObject with column position & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'REAL' from a data value of type 'java.sql.Clob'.
+ updateObject with column name & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'REAL' from a data value of type 'java.sql.Clob'.
updateObject with column position & Date object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'REAL'.
updateObject with column name & Date object as parameters
@@ -2169,6 +2371,10 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'REAL'.
updateObject with column name & TimeStamp object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'REAL'.
+ updateObject with column position & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'REAL' from a data value of type 'java.sql.Blob'.
+ updateObject with column name & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'REAL' from a data value of type 'java.sql.Blob'.
updateObject with column position & Boolean object as parameters
updateObject with column name & Boolean object as parameters
updateObject with column position & null as parameters
@@ -2192,6 +2398,10 @@
Got expected exception : An attempt was made to put a data value of type
'byte[]' into a data value of type 'DOUBLE'.
updateObject with column name & bytes[] array as parameters
Got expected exception : An attempt was made to put a data value of type
'byte[]' into a data value of type 'DOUBLE'.
+ updateObject with column position & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'DOUBLE' from a data value of type 'java.sql.Clob'.
+ updateObject with column name & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'DOUBLE' from a data value of type 'java.sql.Clob'.
updateObject with column position & Date object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'DOUBLE'.
updateObject with column name & Date object as parameters
@@ -2204,6 +2414,10 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'DOUBLE'.
updateObject with column name & TimeStamp object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'DOUBLE'.
+ updateObject with column position & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'DOUBLE' from a data value of type 'java.sql.Blob'.
+ updateObject with column name & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'DOUBLE' from a data value of type 'java.sql.Blob'.
updateObject with column position & Boolean object as parameters
updateObject with column name & Boolean object as parameters
updateObject with column position & null as parameters
@@ -2225,12 +2439,20 @@
updateObject with column name & String object as parameters
updateObject with column position & bytes[] array as parameters
updateObject with column name & bytes[] array as parameters
+ updateObject with column position & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'CHAR' from a data value of type 'java.sql.Clob'.
+ updateObject with column name & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'CHAR' from a data value of type 'java.sql.Clob'.
updateObject with column position & Date object as parameters
updateObject with column name & Date object as parameters
updateObject with column position & Time object as parameters
updateObject with column name & Time object as parameters
updateObject with column position & TimeStamp object as parameters
updateObject with column name & TimeStamp object as parameters
+ updateObject with column position & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'CHAR' from a data value of type 'java.sql.Blob'.
+ updateObject with column name & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'CHAR' from a data value of type 'java.sql.Blob'.
updateObject with column position & Boolean object as parameters
updateObject with column name & Boolean object as parameters
updateObject with column position & null as parameters
@@ -2252,12 +2474,20 @@
updateObject with column name & String object as parameters
updateObject with column position & bytes[] array as parameters
updateObject with column name & bytes[] array as parameters
+ updateObject with column position & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'VARCHAR' from a data value of type 'java.sql.Clob'.
+ updateObject with column name & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'VARCHAR' from a data value of type 'java.sql.Clob'.
updateObject with column position & Date object as parameters
updateObject with column name & Date object as parameters
updateObject with column position & Time object as parameters
updateObject with column name & Time object as parameters
updateObject with column position & TimeStamp object as parameters
updateObject with column name & TimeStamp object as parameters
+ updateObject with column position & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'VARCHAR' from a data value of type 'java.sql.Blob'.
+ updateObject with column name & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'VARCHAR' from a data value of type 'java.sql.Blob'.
updateObject with column position & Boolean object as parameters
updateObject with column name & Boolean object as parameters
updateObject with column position & null as parameters
@@ -2279,12 +2509,20 @@
updateObject with column name & String object as parameters
updateObject with column position & bytes[] array as parameters
updateObject with column name & bytes[] array as parameters
+ updateObject with column position & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'LONG VARCHAR' from a data value of type 'java.sql.Clob'.
+ updateObject with column name & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'LONG VARCHAR' from a data value of type 'java.sql.Clob'.
updateObject with column position & Date object as parameters
updateObject with column name & Date object as parameters
updateObject with column position & Time object as parameters
updateObject with column name & Time object as parameters
updateObject with column position & TimeStamp object as parameters
updateObject with column name & TimeStamp object as parameters
+ updateObject with column position & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'LONG VARCHAR' from a data value of type 'java.sql.Blob'.
+ updateObject with column name & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'LONG VARCHAR' from a data value of type 'java.sql.Blob'.
updateObject with column position & Boolean object as parameters
updateObject with column name & Boolean object as parameters
updateObject with column position & null as parameters
@@ -2320,6 +2558,10 @@
Got expected exception : An attempt was made to put a data value of type
'java.lang.String' into a data value of type 'CHAR () FOR BIT DATA'.
updateObject with column position & bytes[] array as parameters
updateObject with column name & bytes[] array as parameters
+ updateObject with column position & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'CHAR () FOR BIT DATA' from a data value of type 'java.sql.Clob'.
+ updateObject with column name & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'CHAR () FOR BIT DATA' from a data value of type 'java.sql.Clob'.
updateObject with column position & Date object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'CHAR () FOR BIT DATA'.
updateObject with column name & Date object as parameters
@@ -2332,6 +2574,10 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'CHAR () FOR BIT DATA'.
updateObject with column name & TimeStamp object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'CHAR () FOR BIT DATA'.
+ updateObject with column position & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'CHAR () FOR BIT DATA' from a data value of type 'java.sql.Blob'.
+ updateObject with column name & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'CHAR () FOR BIT DATA' from a data value of type 'java.sql.Blob'.
updateObject with column position & Boolean object as parameters
Got expected exception : An attempt was made to put a data value of type
'boolean' into a data value of type 'CHAR () FOR BIT DATA'.
updateObject with column name & Boolean object as parameters
@@ -2369,6 +2615,10 @@
Got expected exception : An attempt was made to put a data value of type
'java.lang.String' into a data value of type 'VARCHAR () FOR BIT DATA'.
updateObject with column position & bytes[] array as parameters
updateObject with column name & bytes[] array as parameters
+ updateObject with column position & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'VARCHAR () FOR BIT DATA' from a data value of type 'java.sql.Clob'.
+ updateObject with column name & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'VARCHAR () FOR BIT DATA' from a data value of type 'java.sql.Clob'.
updateObject with column position & Date object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'VARCHAR () FOR BIT DATA'.
updateObject with column name & Date object as parameters
@@ -2381,6 +2631,10 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'VARCHAR () FOR BIT DATA'.
updateObject with column name & TimeStamp object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'VARCHAR () FOR BIT DATA'.
+ updateObject with column position & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'VARCHAR () FOR BIT DATA' from a data value of type 'java.sql.Blob'.
+ updateObject with column name & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'VARCHAR () FOR BIT DATA' from a data value of type 'java.sql.Blob'.
updateObject with column position & Boolean object as parameters
Got expected exception : An attempt was made to put a data value of type
'boolean' into a data value of type 'VARCHAR () FOR BIT DATA'.
updateObject with column name & Boolean object as parameters
@@ -2418,6 +2672,10 @@
Got expected exception : An attempt was made to put a data value of type
'java.lang.String' into a data value of type 'LONG VARCHAR FOR BIT DATA'.
updateObject with column position & bytes[] array as parameters
updateObject with column name & bytes[] array as parameters
+ updateObject with column position & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'LONG VARCHAR FOR BIT DATA' from a data value of type 'java.sql.Clob'.
+ updateObject with column name & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'LONG VARCHAR FOR BIT DATA' from a data value of type 'java.sql.Clob'.
updateObject with column position & Date object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'LONG VARCHAR FOR BIT DATA'.
updateObject with column name & Date object as parameters
@@ -2430,6 +2688,10 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'LONG VARCHAR FOR BIT DATA'.
updateObject with column name & TimeStamp object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'LONG VARCHAR FOR BIT DATA'.
+ updateObject with column position & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'LONG VARCHAR FOR BIT DATA' from a data value of type 'java.sql.Blob'.
+ updateObject with column name & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'LONG VARCHAR FOR BIT DATA' from a data value of type 'java.sql.Blob'.
updateObject with column position & Boolean object as parameters
Got expected exception : An attempt was made to put a data value of type
'boolean' into a data value of type 'LONG VARCHAR FOR BIT DATA'.
updateObject with column name & Boolean object as parameters
@@ -2467,6 +2729,8 @@
Got expected exception : An attempt was made to put a data value of type
'byte[]' into a data value of type 'CLOB'.
updateObject with column name & bytes[] array as parameters
Got expected exception : An attempt was made to put a data value of type
'byte[]' into a data value of type 'CLOB'.
+ updateObject with column position & Clob object as parameters
+ updateObject with column name & Clob object as parameters
updateObject with column position & Date object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'CLOB'.
updateObject with column name & Date object as parameters
@@ -2479,6 +2743,10 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'CLOB'.
updateObject with column name & TimeStamp object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'CLOB'.
+ updateObject with column position & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'CLOB' from a data value of type 'java.sql.Blob'.
+ updateObject with column name & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'CLOB' from a data value of type 'java.sql.Blob'.
updateObject with column position & Boolean object as parameters
Got expected exception : An attempt was made to put a data value of type
'boolean' into a data value of type 'CLOB'.
updateObject with column name & Boolean object as parameters
@@ -2518,6 +2786,10 @@
Got expected exception : An attempt was made to put a data value of type
'byte[]' into a data value of type 'DATE'.
updateObject with column name & bytes[] array as parameters
Got expected exception : An attempt was made to put a data value of type
'byte[]' into a data value of type 'DATE'.
+ updateObject with column position & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'DATE' from a data value of type 'java.sql.Clob'.
+ updateObject with column name & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'DATE' from a data value of type 'java.sql.Clob'.
updateObject with column position & Date object as parameters
updateObject with column name & Date object as parameters
updateObject with column position & Time object as parameters
@@ -2526,6 +2798,10 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Time' into a data value of type 'DATE'.
updateObject with column position & TimeStamp object as parameters
updateObject with column name & TimeStamp object as parameters
+ updateObject with column position & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'DATE' from a data value of type 'java.sql.Blob'.
+ updateObject with column name & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'DATE' from a data value of type 'java.sql.Blob'.
updateObject with column position & Boolean object as parameters
Got expected exception : An attempt was made to put a data value of type
'boolean' into a data value of type 'DATE'.
updateObject with column name & Boolean object as parameters
@@ -2565,6 +2841,10 @@
Got expected exception : An attempt was made to put a data value of type
'byte[]' into a data value of type 'TIME'.
updateObject with column name & bytes[] array as parameters
Got expected exception : An attempt was made to put a data value of type
'byte[]' into a data value of type 'TIME'.
+ updateObject with column position & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'TIME' from a data value of type 'java.sql.Clob'.
+ updateObject with column name & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'TIME' from a data value of type 'java.sql.Clob'.
updateObject with column position & Date object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'TIME'.
updateObject with column name & Date object as parameters
@@ -2573,6 +2853,10 @@
updateObject with column name & Time object as parameters
updateObject with column position & TimeStamp object as parameters
updateObject with column name & TimeStamp object as parameters
+ updateObject with column position & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'TIME' from a data value of type 'java.sql.Blob'.
+ updateObject with column name & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'TIME' from a data value of type 'java.sql.Blob'.
updateObject with column position & Boolean object as parameters
Got expected exception : An attempt was made to put a data value of type
'boolean' into a data value of type 'TIME'.
updateObject with column name & Boolean object as parameters
@@ -2612,12 +2896,20 @@
Got expected exception : An attempt was made to put a data value of type
'byte[]' into a data value of type 'TIMESTAMP'.
updateObject with column name & bytes[] array as parameters
Got expected exception : An attempt was made to put a data value of type
'byte[]' into a data value of type 'TIMESTAMP'.
+ updateObject with column position & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'TIMESTAMP' from a data value of type 'java.sql.Clob'.
+ updateObject with column name & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'TIMESTAMP' from a data value of type 'java.sql.Clob'.
updateObject with column position & Date object as parameters
updateObject with column name & Date object as parameters
updateObject with column position & Time object as parameters
updateObject with column name & Time object as parameters
updateObject with column position & TimeStamp object as parameters
updateObject with column name & TimeStamp object as parameters
+ updateObject with column position & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'TIMESTAMP' from a data value of type 'java.sql.Blob'.
+ updateObject with column name & Blob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'TIMESTAMP' from a data value of type 'java.sql.Blob'.
updateObject with column position & Boolean object as parameters
Got expected exception : An attempt was made to put a data value of type
'boolean' into a data value of type 'TIMESTAMP'.
updateObject with column name & Boolean object as parameters
@@ -2655,6 +2947,10 @@
Got expected exception : An attempt was made to put a data value of type
'java.lang.String' into a data value of type 'BLOB'.
updateObject with column position & bytes[] array as parameters
updateObject with column name & bytes[] array as parameters
+ updateObject with column position & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'BLOB' from a data value of type 'java.sql.Clob'.
+ updateObject with column name & Clob object as parameters
+ Got expected exception : An attempt was made to get a data value of type
'BLOB' from a data value of type 'java.sql.Clob'.
updateObject with column position & Date object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Date' into a data value of type 'BLOB'.
updateObject with column name & Date object as parameters
@@ -2667,6 +2963,8 @@
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'BLOB'.
updateObject with column name & TimeStamp object as parameters
Got expected exception : An attempt was made to put a data value of type
'java.sql.Timestamp' into a data value of type 'BLOB'.
+ updateObject with column position & Blob object as parameters
+ updateObject with column name & Blob object as parameters
updateObject with column position & Boolean object as parameters
Got expected exception : An attempt was made to put a data value of type
'boolean' into a data value of type 'BLOB'.
updateObject with column name & Boolean object as parameters
@@ -2689,6 +2987,8 @@
updateDate and then cancelRowUpdates
updateTime and then cancelRowUpdates
updateTimestamp and then cancelRowUpdates
+ updateClob and then cancelRowUpdates
+ updateBlob and then cancelRowUpdates
Positive Test24a - after updateXXX, try cancelRowUpdates and then deleteRow
column 1 on this row before updateInt is 1
column 1 on this row after updateInt is 234
@@ -2772,7 +3072,7 @@
{2,bb }
{3,cc }
SQL State : 42X31
-Got expected exception Column 'C2' is not in FOR UPDATE list of cursor
'SQLCUR528'.
+Got expected exception Column 'C2' is not in FOR UPDATE list of cursor
'SQLCUR539'.
Make sure the contents of table are unchanged
C1,C2
-- --
Index:
java/testing/org/apache/derbyTesting/functionTests/master/jdk14/updatableResultSet.out
===================================================================
---
java/testing/org/apache/derbyTesting/functionTests/master/jdk14/updatableResultSet.out
(revision 161347)
+++
java/testing/org/apache/derbyTesting/functionTests/master/jdk14/updatableResultSet.out
(working copy)
@@ -51,6 +51,8 @@
Got expected exception 'updateRow' not allowed because the ResultSet is not an
updatable ResultSet.
Negative Test6 - request updatable resultset for sql with FOR READ ONLY clause
Make sure that we got CONCUR_READ_ONLY? true
+Jira issue Derby-159 : Warnings raised by Derby are not getting passed to the
Client in Network Server Mode
+Will see the warnings in embedded mode only
Expected warnings on resultset = java.sql.SQLWarning: ResultSet not updatable.
Query does not qualify to generate an updatable ResultSet.
Now attempting to send a delete on a sql with FOR READ ONLY clause.
SQL State : XJ083
@@ -64,6 +66,8 @@
SQL State : 24000
Got expected exception Invalid cursor state - no current row.
Now attempt a updateRow without first doing next on the resultset.
+In embedded mode, updateRow will check if it is on a row or not even though no
changes have been made to the row using updateXXX
+In Network Server mode, if no updateXXX were issued before updateRow, then
updateRow is a no-op and doesn't check if it is on a row or not
SQL State : 24000
Got expected exception Invalid cursor state - no current row.
ResultSet is positioned after the last row. attempt to deleteRow at this point
should fail!
@@ -122,7 +126,8 @@
JDBC 2.0 updatable resultset apis on this ResultSet object will pass because
this is an updatable resultset
column 1 on this row before deleteRow is 1
column 2 on this row before deleteRow is aa
-Since after deleteRow(), ResultSet is positioned before the next row, getXXX
will fail
+Since after deleteRow(), in embedded mode, ResultSet is positioned before the
next row, getXXX will fail
+In Network Server mode, the ResultSet stays on the deleted row after deleteRow
and hence no error for getXXX
SQL State : 24000
Got expected exception Invalid cursor state - no current row.
calling deleteRow again w/o first positioning the ResultSet on the next row
will fail
@@ -135,7 +140,8 @@
column 1 on this row after updateInt is 234
column 2 on this row before updateString is aa
now updateRow on the row
-Since after updateRow(), ResultSet is positioned before the next row, getXXX
will fail
+Since after updateRow(), in embedded mode, ResultSet is positioned before the
next row, getXXX will fail
+In Network Server mode, the ResultSet stays on the updated row after updateRow
and hence no error for getXXX
SQL State : 24000
Got expected exception Invalid cursor state - no current row.
calling updateRow again w/o first positioning the ResultSet on the next row
will fail
@@ -269,17 +275,37 @@
Positive Test9c - try to updateXXX on a readonly column. Should get error
SQL State : 42X31
Got expected exception Column 'C2' is not in FOR UPDATE list of cursor
'SQLCUR15'.
+attempt to get an updatable resultset using correlation name for an readonly
column. It should work
+The sql is SELECT c1, c2 as col2 FROM t1 abcde FOR UPDATE of c1
Table t1 after updateRow has following rows
C1,C2
-- --
+ {11,aa }
+ {2,bb }
+ {3,cc }
+Positive Test9c - try to updateXXX on a readonly column. Should get error
+SQL State : 42X31
+Got expected exception Column 'C2' is not in FOR UPDATE list of cursor
'SQLCUR17'.
+Table t1 has following rows
+ C1,C2
+ -- --
{1,aa }
{2,bb }
{3,cc }
+Positive Test9d - try to updateXXX on a readonly column with correlation name.
Should get error
+SQL State : 42X31
+Got expected exception Column 'COL2' is not in FOR UPDATE list of cursor
'SQLCUR18'.
+Table t1 has following rows
+ C1,C2
+ -- --
+ {1,aa }
+ {2,bb }
+ {3,cc }
Positive Test10 - 2 updatable resultsets going against the same table, will
they conflict?
delete using first resultset
attempt to send deleteRow on the same row through a different resultset should
throw an exception
SQL State : XCL08
-Got expected exception Cursor 'SQLCUR17' is not on a row.
+Got expected exception Cursor 'SQLCUR20' is not on a row.
Move to next row in the 2nd resultset and then delete using the second
resultset
Positive Test11 - setting the fetch size to > 1 will be ignored by updatable
resultset. Same as updatable cursors
Notice the Fetch Size in run time statistics output.
@@ -3046,7 +3072,7 @@
{2,bb }
{3,cc }
SQL State : 42X31
-Got expected exception Column 'C2' is not in FOR UPDATE list of cursor
'SQLCUR536'.
+Got expected exception Column 'C2' is not in FOR UPDATE list of cursor
'SQLCUR539'.
Make sure the contents of table are unchanged
C1,C2
-- --
Index: java/testing/org/apache/derbyTesting/functionTests/master/resultset.out
===================================================================
--- java/testing/org/apache/derbyTesting/functionTests/master/resultset.out
(revision 161347)
+++ java/testing/org/apache/derbyTesting/functionTests/master/resultset.out
(working copy)
@@ -10,7 +10,7 @@
getColumnLabel(1): I
getColumnName(1): I
getTableName(1): T
-getSchemaName(1):
+getSchemaName(1): APP
getCatalogName(1):
getColumnType(1): 4
getPrecision(1): 10
@@ -29,7 +29,7 @@
getColumnLabel(2): S
getColumnName(2): S
getTableName(2): T
-getSchemaName(2):
+getSchemaName(2): APP
getCatalogName(2):
getColumnType(2): 5
getPrecision(2): 5
@@ -48,7 +48,7 @@
getColumnLabel(3): R
getColumnName(3): R
getTableName(3): T
-getSchemaName(3):
+getSchemaName(3): APP
getCatalogName(3):
getColumnType(3): 7
getPrecision(3): 7
@@ -67,7 +67,7 @@
getColumnLabel(4): D
getColumnName(4): D
getTableName(4): T
-getSchemaName(4):
+getSchemaName(4): APP
getCatalogName(4):
getColumnType(4): 8
getPrecision(4): 15
@@ -86,7 +86,7 @@
getColumnLabel(5): DT
getColumnName(5): DT
getTableName(5): T
-getSchemaName(5):
+getSchemaName(5): APP
getCatalogName(5):
getColumnType(5): 91
getPrecision(5): 10
@@ -105,7 +105,7 @@
getColumnLabel(6): T
getColumnName(6): T
getTableName(6): T
-getSchemaName(6):
+getSchemaName(6): APP
getCatalogName(6):
getColumnType(6): 92
getPrecision(6): 0
@@ -124,7 +124,7 @@
getColumnLabel(7): TS
getColumnName(7): TS
getTableName(7): T
-getSchemaName(7):
+getSchemaName(7): APP
getCatalogName(7):
getColumnType(7): 93
getPrecision(7): 0
@@ -143,7 +143,7 @@
getColumnLabel(8): C
getColumnName(8): C
getTableName(8): T
-getSchemaName(8):
+getSchemaName(8): APP
getCatalogName(8):
getColumnType(8): 1
getPrecision(8): 10
@@ -162,7 +162,7 @@
getColumnLabel(9): V
getColumnName(9): V
getTableName(9): T
-getSchemaName(9):
+getSchemaName(9): APP
getCatalogName(9):
getColumnType(9): 12
getPrecision(9): 40
@@ -181,7 +181,7 @@
getColumnLabel(10): DC
getColumnName(10): DC
getTableName(10): T
-getSchemaName(10):
+getSchemaName(10): APP
getCatalogName(10):
getColumnType(10): 3
getPrecision(10): 10
@@ -200,7 +200,7 @@
getColumnLabel(11): BI
getColumnName(11): BI
getTableName(11): T
-getSchemaName(11):
+getSchemaName(11): APP
getCatalogName(11):
getColumnType(11): -5
getPrecision(11): 19
@@ -219,7 +219,7 @@
getColumnLabel(12): CBD
getColumnName(12): CBD
getTableName(12): T
-getSchemaName(12):
+getSchemaName(12): APP
getCatalogName(12):
getColumnType(12): -2
getPrecision(12): 10
@@ -238,7 +238,7 @@
getColumnLabel(13): VBD
getColumnName(13): VBD
getTableName(13): T
-getSchemaName(13):
+getSchemaName(13): APP
getCatalogName(13):
getColumnType(13): -3
getPrecision(13): 10
@@ -257,7 +257,7 @@
getColumnLabel(14): LVBD
getColumnName(14): LVBD
getTableName(14): T
-getSchemaName(14):
+getSchemaName(14): APP
getCatalogName(14):
getColumnType(14): -4
getPrecision(14): 32700
@@ -276,7 +276,7 @@
getColumnLabel(15): CL
getColumnName(15): CL
getTableName(15): T
-getSchemaName(15):
+getSchemaName(15): APP
getCatalogName(15):
getColumnType(15): 2005
getPrecision(15): 2147483647
@@ -295,7 +295,7 @@
getColumnLabel(16): BL
getColumnName(16): BL
getTableName(16): T
-getSchemaName(16):
+getSchemaName(16): APP
getCatalogName(16):
getColumnType(16): 2004
getPrecision(16): 1073741824