Quantcast
Channel: MySQL Forums - Connector/J, JDBC and Java
Viewing all articles
Browse latest Browse all 884

Default databse transaction isolation level is hardcoded? (no replies)

$
0
0
Hi,

as far as I can see from the source code, driver's fallback isolation level if not properly resolved from db is TRANSACTION_READ_COMMITTED. Code snippets from ConnectionImpl:

{code}
/** isolation level */
private int isolationLevel = java.sql.Connection.TRANSACTION_READ_COMMITTED;

public synchronized int getTransactionIsolation() throws SQLException {
....
if (versionMeetsMinimum(4, 0, 3)) {
query = "SELECT @@session.tx_isolation";
offset = 1;
} else {
query = "SHOW VARIABLES LIKE 'transaction_isolation'";
offset = 2;
}
....
{code}


However I am curious and confused about this method within DatabaseMetaData.java:

{code}
/**
* What's the database's default transaction isolation level? The values are
* defined in java.sql.Connection.
*
* @return the default isolation level
* @throws SQLException
* if a database access error occurs
* @see Connection
*/
public int getDefaultTransactionIsolation() throws SQLException {
if (this.conn.supportsIsolationLevel()) {
return java.sql.Connection.TRANSACTION_READ_COMMITTED;
}

return java.sql.Connection.TRANSACTION_NONE;
}
{code}



Shoudn't this return the database's default since it has been resolved? Why is it hardcoded? Maybe you mean the driver's default if it cannot be resolved from the db, as implemented in ConnectionImpl.java? Maybe the method documentation is wrong?

Thanks in advance!

Viewing all articles
Browse latest Browse all 884

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>