Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7066253

Browse files
committed
Read transactions don't work on 7.0.x db's 2nd patch
Here is a revised patch with Barry's suggestions implementedDave Cramer
1 parent6ea41dc commit7066253

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

‎src/interfaces/jdbc/org/postgresql/Connection.java

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
importorg.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 {
749749
if (autoCommit)
750750
ExecSQL("end");
751751
else {
752-
ExecSQL("begin; " +getIsolationLevelSQL());
752+
if (haveMinimumServerVersion("7.1")){
753+
ExecSQL("begin;"+getIsolationLevelSQL());
754+
}else{
755+
ExecSQL("begin");
756+
ExecSQL(getIsolationLevelSQL());
757+
}
753758
}
754759
this.autoCommit =autoCommit;
755760
}
@@ -778,7 +783,13 @@ public boolean getAutoCommit() throws SQLException {
778783
publicvoidcommit()throwsSQLException {
779784
if (autoCommit)
780785
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+
}
782793
}
783794

784795
/**
@@ -792,7 +803,13 @@ public void commit() throws SQLException {
792803
publicvoidrollback()throwsSQLException {
793804
if (autoCommit)
794805
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+
}
796813
}
797814

798815
/**
@@ -878,21 +895,21 @@ protected String getIsolationLevelSQL() throws SQLException {
878895
if (haveMinimumServerVersion("7.1")) {
879896
return"";
880897
}
881-
Stringq ="SET TRANSACTION ISOLATION LEVEL";
898+
StringBuffersb =newStringBuffer("SET TRANSACTION ISOLATION LEVEL");
882899

883900
switch(isolationLevel) {
884901
casejava.sql.Connection.TRANSACTION_READ_COMMITTED:
885-
q =q +" READ COMMITTED";
902+
sb.append(" READ COMMITTED");
886903
break;
887904

888905
casejava.sql.Connection.TRANSACTION_SERIALIZABLE:
889-
q =q +" SERIALIZABLE";
906+
sb.append(" SERIALIZABLE");
890907
break;
891908

892909
default:
893910
thrownewPSQLException("postgresql.con.isolevel",newInteger(isolationLevel));
894911
}
895-
returnq;
912+
returnsb.toString();
896913
}
897914

898915
/**

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp