Description
When an XA Transaction is started the isolation level set with SET CURRENT ISOLATION gets reset to CS.
Embedded setTransactionIsolation does not have this problem but this problem is the root cause of DERBY-414 because client implements setTransactionIsolation by sending SET CURRENT ISOLATION
$ java TestSetCurrentIsolation
Database product: Apache Derby
Database version: 10.2.0.0 alpha
Driver name: Apache Derby Embedded JDBC Driver
Driver version: 10.2.0.0 alpha
SET CURRENT ISOLATION = UR
CURRENT ISOLATION: UR
getTransactionIsolation:TRANSACTION_READ_UNCOMMITTED:1
Isolation level after xa start
CURRENT ISOLATION: CS
getTransactionIsolation:TRANSACTION_READ_COMMITTED:2
$
import java.sql.*;
import javax.sql.*;
import javax.transaction.xa.*;
public class TestSetCurrentIsolation
{
public static void main(String[] args) throws Throwable
{
try
catch (SQLException sqlX)
{ System.out.println("Error on thread 1."); do sqlX.printStackTrace(); while ((sqlX = sqlX.getNextException()) != null); }catch (Throwable th)
{ System.out.println("Error on thread 1."); do th.printStackTrace(); while ((th = th.getCause()) != null); }}
/**
- @param conn
- @throws SQLException
*/
private static void showIsolationLevel(Connection conn) throws SQLException { PreparedStatement ps = conn.prepareStatement("VALUES CURRENT ISOLATION"); ResultSet rs = ps.executeQuery(); //ResultSet rs = conn.createStatement().executeQuery("VALUES CURRENT ISOLATION"); rs.next(); System.out.println("CURRENT ISOLATION: " + rs.getString(1)); System.out.println("getTransactionIsolation:" + getIsoLevelName(conn.getTransactionIsolation())); }
public static String getIsoLevelName(int level)
{
switch (level)
return "UNEXPECTED_ISO_LEVEL";
}
}