// setClob()
ResultSet rsc = s
.executeQuery("SELECT C FROM PM.LOB_GET WHERE ID = 1");
rsc.next();
Clob tester = rsc.getClob(1);
rsc.close();
psi.setClob(1, tester);
psi.executeUpdate();
getValidValue(psq, jdbcTypes[type], "setClob");
worked = true;
} catch (SQLException sqle) {
sqleResult = sqle;
worked = false;
}
judge_setXXX(worked, sqleResult, 16, type);
}
{
s.execute("DELETE FROM PM.TYPE_AS");
SQLException sqleResult = null;
boolean worked;
try {
// setClob() as batch
ResultSet rsc = s
.executeQuery("SELECT C FROM PM.LOB_GET WHERE ID = 1");
rsc.next();
Clob tester = rsc.getClob(1);
rsc.close();
psi.setClob(1, tester);
psi.addBatch();
psi.executeBatch();
getValidValue(psq, jdbcTypes[type], "setClob");
worked = true;
} catch (SQLException sqle) {
sqleResult = sqle;
worked = false;
}
judge_setXXX(worked, sqleResult, 16, type);
}
{
s.execute("DELETE FROM PM.TYPE_AS");
SQLException sqleResult = null;
boolean worked;
try {
// setClob(null)
psi.setClob(1, null);
psi.executeUpdate();
getValidValue(psq, jdbcTypes[type], "setClob");
worked = true;
} catch (SQLException sqle) {
sqleResult = sqle;
worked = false;
}
judge_setXXX(worked, sqleResult, 16, type);
}
{
s.execute("DELETE FROM PM.TYPE_AS");
SQLException sqleResult = null;
boolean worked;
try {
// setClob(null) as batch
psi.setClob(1, null);
psi.addBatch();
psi.executeBatch();
getValidValue(psq, jdbcTypes[type], "setClob");
worked = true;
} catch (SQLException sqle) {
sqleResult = sqle;
worked = false;
}
judge_setXXX(worked, sqleResult, 16, type);
}
{
s.execute("DELETE FROM PM.TYPE_AS");
SQLException sqleResult = null;
boolean worked;
try {
// setBlob()
ResultSet rsc = s
.executeQuery("SELECT B FROM PM.LOB_GET WHERE ID = 1");
rsc.next();
Blob tester = rsc.getBlob(1);
rsc.close();
psi.setBlob(1, tester);
psi.executeUpdate();
getValidValue(psq, jdbcTypes[type], "setBlob");
worked = true;
} catch (SQLException sqle) {
sqleResult = sqle;
worked = false;
}
judge_setXXX(worked, sqleResult, 17, type);
}
{
s.execute("DELETE FROM PM.TYPE_AS");
SQLException sqleResult = null;
boolean worked;
try {
// setBlob() as batch
ResultSet rsc = s
.executeQuery("SELECT B FROM PM.LOB_GET WHERE ID = 1");
rsc.next();
Blob tester = rsc.getBlob(1);
rsc.close();
psi.setBlob(1, tester);
psi.addBatch();
psi.executeBatch();
getValidValue(psq, jdbcTypes[type], "setBlob");
worked = true;
} catch (SQLException sqle) {
sqleResult = sqle;
worked = false;
}
judge_setXXX(worked, sqleResult, 17, type);
}
{
s.execute("DELETE FROM PM.TYPE_AS");
SQLException sqleResult = null;
boolean worked;
try {
// Blob(null)
psi.setBlob(1, null);
psi.executeUpdate();
getValidValue(psq, jdbcTypes[type], "setBlob");
worked = true;
} catch (SQLException sqle) {
sqleResult = sqle;
worked = false;
}
judge_setXXX(worked, sqleResult, 17, type);
}
{
s.execute("DELETE FROM PM.TYPE_AS");
SQLException sqleResult = null;
boolean worked;
try {
// setBlob(null) as batch
psi.setBlob(1, null);
psi.addBatch();
psi.executeBatch();
getValidValue(psq, jdbcTypes[type], "setBlob");
worked = true;
} catch (SQLException sqle) {
sqleResult = sqle;
worked = false;
}
judge_setXXX(worked, sqleResult, 17, type);
}
{
s.execute("DELETE FROM PM.TYPE_AS");
SQLException sqleResult = null;
boolean worked;
try {
// setUnicodeStream()
byte[] data = new byte[6];
data[0] = (byte) 0x4;
data[1] = (byte) 0x3;
data[2] = (byte) 0xca;
data[3] = (byte) 0xfe;
data[4] = (byte) 0x00;
data[5] = (byte) 0x32;
try {
psi.setUnicodeStream(1, new java.io.ByteArrayInputStream(
data), 6);
} catch (NoSuchMethodError e) {
// ResultSet.setUnicodeStream not present - correct for
// JSR169
}
if (JDBC.vmSupportsJDBC3()) {
psi.executeUpdate();
getValidValue(psq, jdbcTypes[type], "setUnicodeStream");
}
worked = true;
} catch (SQLException sqle) {
sqleResult = sqle;
worked = false;
}
if (JDBC.vmSupportsJDBC3())
judge_setXXX(worked, sqleResult, 14, type);
}
// setObject(null)
{
s.execute("DELETE FROM PM.TYPE_AS");
SQLException sqleResult = null;
boolean worked;
try {
// should never work!
// setObject(null)
psi.setObject(1, null);
psi.executeUpdate();
getValidValue(psq, jdbcTypes[type], "setObject");
worked = true;
} catch (SQLException sqle) {
sqleResult = sqle;
worked = false;
}
if (worked)
fail("FAIL: setObject(null) not valid");
}
{
s.execute("DELETE FROM PM.TYPE_AS");
SQLException sqleResult = null;
boolean worked;
try {
// should never work!
// setObject(null) as batch
psi.setObject(1, null);
psi.addBatch();
psi.executeBatch();
getValidValue(psq, jdbcTypes[type], "setObject");
worked = true;
} catch (SQLException sqle) {
sqleResult = sqle;
worked = false;
}
if (worked)
fail("FAIL: setObject(1,null) did not throw exception");
}
setXXX_setObject(s, psi, psq, type, validString[type], "java.lang.String", 0);
if (HAVE_BIG_DECIMAL)
setXXX_setObject(s, psi, psq, type, BigDecimal.valueOf(98L),
"java.math.BigDecimal", 1);
setXXX_setObject(s, psi, psq, type, Boolean.TRUE, "java.lang.Boolean",
2);
// DERBY-1500: setObject() should work for Byte and Short too.
setXXX_setObject(s, psi, psq, type, new Byte((byte) 98),
"java.lang.Byte", 1);
setXXX_setObject(s, psi, psq, type, new Short((short) 98),
"java.lang.Short", 2);
setXXX_setObject(s, psi, psq, type, new Integer(98),
"java.lang.Integer", 3);
setXXX_setObject(s, psi, psq, type, new Long(98), "java.lang.Long", 4);
setXXX_setObject(s, psi, psq, type, new Float(98.0f),
"java.lang.Float", 5);
setXXX_setObject(s, psi, psq, type, new Double(98.0d),
"java.lang.Double", 6);
{
byte[] data = { 0x4, 0x3 };
setXXX_setObject(s, psi, psq, type, data, "byte[]", 7);
}
setXXX_setObject(s, psi, psq, type,
java.sql.Date.valueOf("2004-02-14"), "java.sql.Date", 8);
setXXX_setObject(s, psi, psq, type, java.sql.Time.valueOf("00:00:00"),
"java.sql.Time", 9);
setXXX_setObject(s, psi, psq, type, java.sql.Timestamp
.valueOf("2004-02-14 00:00:00.0"), "java.sql.Timestamp", 10);
s.getConnection().commit();
// Test setObject with Blob
{
ResultSet rsc = s
.executeQuery("SELECT B FROM PM.LOB_GET WHERE ID = 1");
rsc.next();
Blob tester = rsc.getBlob(1);
rsc.close();
setXXX_setObject(s, psi, psq, type, tester, "java.sql.Blob", 11);
}
// Test setObject with Clob
{
ResultSet rsc = s
.executeQuery("SELECT C FROM PM.LOB_GET WHERE ID = 1");
rsc.next();
Clob tester = rsc.getClob(1);
rsc.close();
setXXX_setObject(s, psi, psq, type, tester, "java.sql.Clob", 12);
}
}