Here are a couple of important lines from the documentation:
[quote]Sets this connection’s auto-commit mode. If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either the method commit or the method rollback. By default, new connections are in auto-commit mode. The commit occurs when the statement completes or the next execute occurs, whichever comes first. In the case of statements returning a ResultSet, the statement completes when the last row of the ResultSet has been retrieved or the ResultSet has been closed. In advanced cases, a single statement may return multiple results as well as output parameter values. In these cases the commit occurs when all results and output parameter values have been retrieved.
[/quote]
What this means is, if you don’t setAutoCommit( false ) before you start, EVERY SINGLE TRANSACTION commits to the database immediately every time you write to it, and every read results in a read from the database, as if you were using the command line interpreter for MySQL.
[quote]TRANSACTION_READ_UNCOMMITTED
public static final int TRANSACTION_READ_UNCOMMITTEDDirty reads, non-repeatable reads and phantom reads can occur. This level allows a row changed by one transaction to be read by another transaction before any changes in that row have been committed (a “dirty read”). If any of the changes are rolled back, the second transaction will have retrieved an invalid row.
[/quote]
This is a flag you can set using setTransactionIsolation. Theoretically you can have “dirty reads” meaning that before a transaction commits you can be reading the data in other transactions. This is somewhat dangerous in my mind.
To get to what you might be trying to do, are you asking to fail a transaction if someone else is writing to it? Are you trying to prevent a “block” on a transaction?
If so, I think you need to control transactions yourself, and look for a transaction that throws an exception (the SQLSTATE is being elusive right now, so I don’t know which error to look for), and then in your catch clause, do the read information you want to do.