how to use transaction isolation

Поиск
Список
Период
Сортировка
От Gong
Тема how to use transaction isolation
Дата
Msg-id 006701c89adb$9dd69420$2200080a@netcde22364c1c
обсуждение исходный текст
Ответы Re: how to use transaction isolation
Список pgsql-general
In the java code below, I set the transaction isolation to serialization.
 
public class IsolationTest {

    private static String select = "select * from tmp where url = 'aaa'";
    public static void main(String[] args) throws Exception{
        //ConncetionFactory is a factory class for managing connection
        Connection con = ConnectionFactory.getConnection();  
        con.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
        con.setAutoCommit(false);
        Statement smt = con.createStatement();
        ResultSet r1 = smt.executeQuery(select);
        System.out.println(r1.next());  //(1)   
        con.commit();               //(2)

        ResultSet r2 = smt.executeQuery(select);
        System.out.println(r2.next());  //(3)
        con.commit();
        smt.close();        

        ConnectionFactory.closeConnection();
    }
}
 
I set a break point at (2), then I run this code in debug mode. When it suspended at (2), line(1) print "false". Then, I execute an insert statement in pgadmin: insert into tmp values('aaa'), after that I continued to run the code, and line(3) print "true". I have set the transaction isolation to serialization, didn't the two select statements print the same result?
 
btw: postgresql version is 8.2, jdbc version is postgresql-8.2-506.jdbc3.jar, and jdk version is 1.5

В списке pgsql-general по дате отправления:

Предыдущее
От: Sam Mason
Дата:
Сообщение: Re: percentile rank query
Следующее
От: Erik Jones
Дата:
Сообщение: Re: Way to shutdown/freeze/stop an individual database without taking postmaster down?