Subject | Re: Transaction question |
---|---|
Author | Roman Rokytskyy |
Post date | 2003-06-12T18:53:10Z |
Hi,
automatically before the first statement is executed. Transaction do
not have names and there can be only one transaction per connection.
Transaction isolation level is set using
Connection.setTransactionIsolation(int) method.
You code should look like this:
Connection con = connex.getConnection();
try {
con.setAutoCommit(false);
con.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
Statement stmt = con.createStatement();
try {
ResultSet rs = stmt.executeQuery("select * from my_table");
...
} finally {
stmt.close();
}
} finally {
con.close();
}
con.commit();
> I'm trying to create a transaction with this code:Try to read JDBC tutorial. Transactions in JDBC are started
>
> try
> {
> conex.getConnection().setAutoCommit(false);
> conex.getConnection().createStatement().execute("set transaction
> name tr1 read committed");
> ...
> Can anybody guide me on how to begin-commit a transaction.
automatically before the first statement is executed. Transaction do
not have names and there can be only one transaction per connection.
Transaction isolation level is set using
Connection.setTransactionIsolation(int) method.
You code should look like this:
Connection con = connex.getConnection();
try {
con.setAutoCommit(false);
con.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
Statement stmt = con.createStatement();
try {
ResultSet rs = stmt.executeQuery("select * from my_table");
...
} finally {
stmt.close();
}
} finally {
con.close();
}
con.commit();