savepoint not supported with oracle 8i
when I am using the oracle thin driver I'm getting the following error
Exception in thread "main" java.lang.AbstractMethodError: oracle.jdbc.driver.OracleDatabaseMetaData.supportsSavepoints()Z
at Svpt1.main(Svpt1.java:31)
but when odbc driver is used the
Checking savepoint support ...
Savepoint is not supported
Insert record(10, 'newregion1') ...
Establish savepoint 1 ...
Unexpected Exception null
java.lang.UnsupportedOperationException
at sun.jdbc.odbc.JdbcOdbcConnection.setSavepoint(JdbcOdbcConnection.java
:1713)
at Svpt1.main(Svpt1.java:49)
please tell me why this difference and how can I use savepoint with oracle 8i.
I'm using Oracle 8i and j2sdk1.5.0_06
import java.sql.*;
public class Svpt1
{
public static void main(String args[])
{
Connection conn = null;
Statement stmt = null;
int rows = 0;
try
{
// Load the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:gdn";
// Connect to the database
conn = DriverManager.getConnection (jdbcUrl, "srg", "srg");
// Create a Statement
stmt = conn.createStatement();
// Cleanup table to original state
stmt.execute("DELETE FROM employees WHERE ssn=10");
// Turn off the auto-commit mode
conn.setAutoCommit(false);
DatabaseMetaData dbmd = conn.getMetaData();
// Check whether Savepoint is supported
show("Checking savepoint support ...");
if (dbmd.supportsSavepoints())
show("Savepoint is supported");
else
show("Savepoint is not supported");
// Insert a new record into the "regions" table
show("Insert record(10, 'newregion1') ...");
rows = stmt.executeUpdate("insert into employees(ssn,name) values (10, 'newregion1')");
// Establish the first savepoint (named)
show("Establish savepoint 1 ...");
Savepoint svpt1 = conn.setSavepoint("svpt_1");
// Insert a second record into the "regions" table
show("Insert record(11, 'newregion2') ...");
rows = stmt.executeUpdate("insert into employees(ssn,name) values (11, 'newregion2')");
// Establish the second savepoint (named)
show("Establish savepoint 2 ...");
Savepoint svpt2 = conn.setSavepoint("svpt_2");
// Establish the third savepoint (unnamed)
show("Establish savepoint 3 ...");
Savepoint svpt3 = conn.setSavepoint();
// Insert a third record into the "regions" table
show("Insert record(12, 'newregion3') ...");
rows = stmt.executeUpdate("insert into employees(ssn,name) values (12, 'newregion3')");
// Check names and ids of established Savepoints
show("The name of txn savepoint 1 is: " + svpt1.getSavepointName());
show("The name of txn savepoint 2 is: " + svpt2.getSavepointName());
show("The id of txn savepoint 3 is: " + svpt3.getSavepointId());
// Rollback to the first savepoint
show("Rollback to savepoint 1 ...");
conn.rollback(svpt1);
// Commit the transaction
show("Commit the transaction ...");
conn.commit();
// Close the Statement
stmt.close();
// Close the Connection
conn.close();
}//try
catch(SQLException sqlexc)
{
show("Unexpected SQL Exception " + sqlexc.getMessage());
sqlexc.printStackTrace();
}
catch(Exception exc)
{
show("Unexpected Exception " + exc.getMessage());
exc.printStackTrace();
}
}//main
static void show(String mesg)
{
System.out.println(mesg);
}
}//class
thanks in advance.