1111import org .postgresql .core .*;
1212
1313/**
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 $
1515 *
1616 * This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
1717 * JDBC2 versions of the Connection class.
@@ -749,7 +749,12 @@ public void setAutoCommit(boolean autoCommit) throws SQLException {
749749if (autoCommit )
750750ExecSQL ("end" );
751751else {
752- ExecSQL ("begin; " +getIsolationLevelSQL ());
752+ if (haveMinimumServerVersion ("7.1" )){
753+ ExecSQL ("begin;" +getIsolationLevelSQL ());
754+ }else {
755+ ExecSQL ("begin" );
756+ ExecSQL (getIsolationLevelSQL ());
757+ }
753758}
754759this .autoCommit =autoCommit ;
755760 }
@@ -778,7 +783,13 @@ public boolean getAutoCommit() throws SQLException {
778783public void commit ()throws SQLException {
779784if (autoCommit )
780785return ;
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+ }
782793 }
783794
784795/**
@@ -792,7 +803,13 @@ public void commit() throws SQLException {
792803public void rollback ()throws SQLException {
793804if (autoCommit )
794805return ;
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+ }
796813 }
797814
798815/**
@@ -878,21 +895,21 @@ protected String getIsolationLevelSQL() throws SQLException {
878895if (haveMinimumServerVersion ("7.1" )) {
879896return "" ;
880897 }
881- String q ="SET TRANSACTION ISOLATION LEVEL" ;
898+ StringBuffer sb =new StringBuffer ( "SET TRANSACTION ISOLATION LEVEL" ) ;
882899
883900switch (isolationLevel ) {
884901case java .sql .Connection .TRANSACTION_READ_COMMITTED :
885- q = q + " READ COMMITTED" ;
902+ sb . append ( " READ COMMITTED" ) ;
886903break ;
887904
888905case java .sql .Connection .TRANSACTION_SERIALIZABLE :
889- q = q + " SERIALIZABLE" ;
906+ sb . append ( " SERIALIZABLE" ) ;
890907break ;
891908
892909default :
893910throw new PSQLException ("postgresql.con.isolevel" ,new Integer (isolationLevel ));
894911}
895- return q ;
912+ return sb . toString () ;
896913 }
897914
898915/**