11
11
import org .postgresql .core .*;
12
12
13
13
/**
14
- * $Id: Connection.java,v 1.27 2001/09/06 03:13:34 momjian Exp $
14
+ * $Id: Connection.java,v 1.28 2001/09/07 22:17:02 momjian Exp $
15
15
*
16
16
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
17
17
* JDBC2 versions of the Connection class.
@@ -749,7 +749,12 @@ public void setAutoCommit(boolean autoCommit) throws SQLException {
749
749
if (autoCommit )
750
750
ExecSQL ("end" );
751
751
else {
752
- ExecSQL ("begin; " + getIsolationLevelSQL ());
752
+ if (haveMinimumServerVersion ("7.1" )){
753
+ ExecSQL ("begin;" +getIsolationLevelSQL ());
754
+ }else {
755
+ ExecSQL ("begin" );
756
+ ExecSQL (getIsolationLevelSQL ());
757
+ }
753
758
}
754
759
this .autoCommit = autoCommit ;
755
760
}
@@ -778,7 +783,13 @@ public boolean getAutoCommit() throws SQLException {
778
783
public void commit () throws SQLException {
779
784
if (autoCommit )
780
785
return ;
781
- ExecSQL ("commit; begin; " + getIsolationLevelSQL ());
786
+ if (haveMinimumServerVersion ("7.1" )){
787
+ ExecSQL ("commit;begin;" +getIsolationLevelSQL ());
788
+ }else {
789
+ ExecSQL ("commit" );
790
+ ExecSQL ("begin" );
791
+ ExecSQL (getIsolationLevelSQL ());
792
+ }
782
793
}
783
794
784
795
/**
@@ -792,7 +803,13 @@ public void commit() throws SQLException {
792
803
public void rollback () throws SQLException {
793
804
if (autoCommit )
794
805
return ;
795
- ExecSQL ("rollback; begin; " + getIsolationLevelSQL ());
806
+ if (haveMinimumServerVersion ("7.1" )){
807
+ ExecSQL ("rollback; begin;" +getIsolationLevelSQL ());
808
+ }else {
809
+ ExecSQL ("rollback" );
810
+ ExecSQL ("begin" );
811
+ ExecSQL (getIsolationLevelSQL ());
812
+ }
796
813
}
797
814
798
815
/**
@@ -878,21 +895,21 @@ protected String getIsolationLevelSQL() throws SQLException {
878
895
if (haveMinimumServerVersion ("7.1" )) {
879
896
return "" ;
880
897
}
881
- String q = "SET TRANSACTION ISOLATION LEVEL" ;
898
+ StringBuffer sb = new StringBuffer ( "SET TRANSACTION ISOLATION LEVEL" ) ;
882
899
883
900
switch (isolationLevel ) {
884
901
case java .sql .Connection .TRANSACTION_READ_COMMITTED :
885
- q = q + " READ COMMITTED" ;
902
+ sb . append ( " READ COMMITTED" ) ;
886
903
break ;
887
904
888
905
case java .sql .Connection .TRANSACTION_SERIALIZABLE :
889
- q = q + " SERIALIZABLE" ;
906
+ sb . append ( " SERIALIZABLE" ) ;
890
907
break ;
891
908
892
909
default :
893
910
throw new PSQLException ("postgresql.con.isolevel" ,new Integer (isolationLevel ));
894
911
}
895
- return q ;
912
+ return sb . toString () ;
896
913
}
897
914
898
915
/**
0 commit comments