throws SQLException
{
boolean passed = true;
PreparedStatement ps_f_r = null;
ResultSet rs;
SQLWarning warning;
Statement s_f_r = null;
s_f_r = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
// We should have gotten no warnings and a read only forward only cursor
warning = conn.getWarnings();
while (warning != null)
{
System.out.println("warning = " + warning);
warning = warning.getNextWarning();
}
conn.clearWarnings();
// Verify that setMaxRows(-1) fails
try
{
s_f_r.setMaxRows(-1);
// Should never get here
System.out.println("setMaxRows(-1) expected to fail");
passed = false;
}
catch (SQLException sqle)
{
/* Check to be sure the exception is the one we expect */
if (!isDerbyNetClient) {
passed = passed && checkException(sqle, "XJ063");
} else {
System.out.println(sqle.getMessage());
}
}
// Verify maxRows still 0
if (s_f_r.getMaxRows() != 0)
{
System.out.println("getMaxRows() expected to return 0");
passed = false;
}
// Verify that result set from statement is
// scroll insensitive and read only
rs = s_f_r.executeQuery("select * from t");
if (rs.getType() != ResultSet.TYPE_FORWARD_ONLY)
{
System.out.println("cursor type = " + rs.getType() +
", not " + ResultSet.TYPE_FORWARD_ONLY);
}
if (rs.getConcurrency() != ResultSet.CONCUR_READ_ONLY)
{
System.out.println("concurrency = " + rs.getConcurrency() +
", not " + ResultSet.CONCUR_READ_ONLY);
}
// Verify that first(), etc. don't work
try
{
rs.first();
// Should never get here
System.out.println("first() expected to fail");
passed = false;
}
catch (SQLException sqle)
{
/* Check to be sure the exception is the one we expect */
if (!isDerbyNetClient) {
passed = passed && checkException(sqle, "XJ061");
} else {
System.out.println(sqle.getMessage());
}
}
try
{
rs.beforeFirst();
// Should never get here
System.out.println("beforeFirst() expected to fail");
passed = false;
}
catch (SQLException sqle)
{
/* Check to be sure the exception is the one we expect */
if (!isDerbyNetClient) {
passed = passed && checkException(sqle, "XJ061");
} else {
System.out.println(sqle.getMessage());
}
}
try
{
rs.isBeforeFirst();
// Should never get here
System.out.println("isBeforeFirst() expected to fail");
passed = false;
}
catch (SQLException sqle)
{
/* Check to be sure the exception is the one we expect */
if (!isDerbyNetClient) {
passed = passed && checkException(sqle, "XJ061");
} else {
System.out.println(sqle.getMessage());
}
}
try
{
rs.isAfterLast();
// Should never get here
System.out.println("isAfterLast() expected to fail");
passed = false;
}
catch (SQLException sqle)
{
/* Check to be sure the exception is the one we expect */
if (!isDerbyNetClient) {
passed = passed && checkException(sqle, "XJ061");
} else {
System.out.println(sqle.getMessage());
}
}
try
{
rs.isFirst();
// Should never get here
System.out.println("isFirst() expected to fail");
passed = false;
}
catch (SQLException sqle)
{
/* Check to be sure the exception is the one we expect */
if (!isDerbyNetClient) {
passed = passed && checkException(sqle, "XJ061");
} else {
System.out.println(sqle.getMessage());
}
}
try
{
rs.isLast();
// Should never get here
System.out.println("isLast() expected to fail");
passed = false;
}
catch (SQLException sqle)
{
/* Check to be sure the exception is the one we expect */
if (!isDerbyNetClient) {
passed = passed && checkException(sqle, "XJ061");
} else {
System.out.println(sqle.getMessage());
}
}
try
{
rs.absolute(1);
// Should never get here
System.out.println("absolute() expected to fail");
passed = false;
}
catch (SQLException sqle)
{
/* Check to be sure the exception is the one we expect */
if (!isDerbyNetClient) {
passed = passed && checkException(sqle, "XJ061");
} else {
System.out.println(sqle.getMessage());
}
}
try
{
rs.relative(1);
// Should never get here
System.out.println("relative() expected to fail");
passed = false;
}
catch (SQLException sqle)
{
/* Check to be sure the exception is the one we expect */
if (!isDerbyNetClient) {
passed = passed && checkException(sqle, "XJ061");
} else {
System.out.println(sqle.getMessage());
}
}
// setFetchDirection should fail
try
{
rs.setFetchDirection(ResultSet.FETCH_FORWARD);
// Should never get here
System.out.println("setFetchDirection() expected to fail");
passed = false;
}
catch (SQLException sqle)
{
/* Check to be sure the exception is the one we expect */
if (!isDerbyNetClient) {
passed = passed && checkException(sqle, "XJ061");
} else {
System.out.println(sqle.getMessage());
}
}
/* Book says that getFetchDirection(), getFetchSize() and
* setFetchSize() are all okay.
*/
if ((rs.getFetchSize() != 1 && !isDerbyNetClient) || (rs.getFetchSize() != 0 && isDerbyNetClient))
{
if (!isDerbyNetClient) {
System.out.println("getFetchSize() expected to return 1");
} else {
System.out.println("getFetchSize() expected to return 0");
}
passed = false;
}
rs.setFetchSize(5);
if (rs.getFetchSize() != 5)
{
System.out.println("getFetchSize() expected to return 5");
passed = false;
}
if (rs.getFetchDirection() != ResultSet.FETCH_FORWARD)
{
System.out.println(
"getFetchDirection() expected to return FETCH_FORWARD, not " +
rs.getFetchDirection());
passed = false;
}
rs.close();
s_f_r.close();
ps_f_r = conn.prepareStatement(
"select * from t",
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
// We should have gotten no warnings and a read only forward only cursor
warning = conn.getWarnings();
while (warning != null)
{
System.out.println("warning = " + warning);
warning = warning.getNextWarning();
}
conn.clearWarnings();
// Verify that result set from statement is
// scroll insensitive and read only