pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Isolation level support with JDBC
2+ messages / 2 participants
[nested] [flat]

* Isolation level support with JDBC
@ 1999-06-01 16:08 Benoit Foucher <benoit@ooc.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Benoit Foucher @ 1999-06-01 16:08 UTC (permalink / raw)
  To: pgsql-interfaces

Hi,

Since two different transaction isolation levels are supported
with Postgres 6.5 (READ_COMMITED and SERIALIZABLE), I've added 
support for setting and getting isolation level with
the two methods java.sql.Connection.setTransactionIsolation and 
java.sql.Connection.getTransactionIsolation. 

I'd like to know if my  modifications are correct (I've never 
developped such stuff before) and if it could be added to the 
jdbc driver sources.

I've attached the patch to this mail.

Thank you!
Regards

Benoit.

-- 
Benoit Foucher                                      mailto:benoit@ooc.com

Attachments:

jdbc.patch (application/octet-stream, 4.8K) download Index: Connection.java =================================================================== RCS file: /usr/local/cvsroot/pgsql/src/interfaces/jdbc/postgresql/Connection.java,v retrieving revision 1.17 diff -u -r1.17 Connection.java --- Connection.java 1999/05/18 23:17:15 1.17 +++ Connection.java 1999/06/01 16:03:28 @@ -36,6 +36,7 @@ public boolean autoCommit = true; public boolean readOnly = false; + public int isolationLevel = java.sql.Connection.TRANSACTION_READ_COMMITTED; public Driver this_driver; private String this_url; @@ -262,6 +263,13 @@ //if(msg.startsWith(dateStyles[i])) //currentDateStyle=i+1; // this is the index of the format //} + + if(msg.startsWith("NOTICE:") && msg.indexOf("TRANSACTION ISOLATION LEVEL")>0) { + msg = msg.substring(msg.indexOf("TRANSACTION ISOLATION LEVEL is ")+31); + if(msg.equals("SERIALIZABLE")) + isolationLevel = java.sql.Connection.TRANSACTION_SERIALIZABLE; + else isolationLevel = java.sql.Connection.TRANSACTION_READ_COMMITTED; + } } /** Index: jdbc1/Connection.java =================================================================== RCS file: /usr/local/cvsroot/pgsql/src/interfaces/jdbc/postgresql/jdbc1/Connection.java,v retrieving revision 1.2 diff -u -r1.2 Connection.java --- jdbc1/Connection.java 1999/05/18 23:17:21 1.2 +++ jdbc1/Connection.java 1999/06/01 16:03:29 @@ -311,7 +311,11 @@ */ public void setTransactionIsolation(int level) throws SQLException { - throw postgresql.Driver.notImplemented(); + if(level == java.sql.Connection.TRANSACTION_READ_COMMITTED) + ExecSQL("set transaction isolation level read commited"); + else if(level == java.sql.Connection.TRANSACTION_SERIALIZABLE) + ExecSQL("set transaction isolation level serializable"); + else throw postgresql.Driver.notImplemented(); } /** @@ -322,7 +326,9 @@ */ public int getTransactionIsolation() throws SQLException { - return java.sql.Connection.TRANSACTION_SERIALIZABLE; + ExecSQL("show transaction isolation level"); + + return isolationLevel; } /** Index: jdbc1/DatabaseMetaData.java =================================================================== RCS file: /usr/local/cvsroot/pgsql/src/interfaces/jdbc/postgresql/jdbc1/DatabaseMetaData.java,v retrieving revision 1.1 diff -u -r1.1 DatabaseMetaData.java --- jdbc1/DatabaseMetaData.java 1999/01/17 04:51:54 1.1 +++ jdbc1/DatabaseMetaData.java 1999/06/01 16:03:41 @@ -1350,7 +1350,7 @@ */ public int getDefaultTransactionIsolation() throws SQLException { - return Connection.TRANSACTION_SERIALIZABLE; + return Connection.TRANSACTION_READ_COMMITTED; } /** @@ -1379,8 +1379,9 @@ { if (level == Connection.TRANSACTION_SERIALIZABLE) return true; - else - return false; + else if(level == Connection.TRANSACTION_READ_COMMITTED) + return true; + else return false; } /** Index: jdbc2/Connection.java =================================================================== RCS file: /usr/local/cvsroot/pgsql/src/interfaces/jdbc/postgresql/jdbc2/Connection.java,v retrieving revision 1.2 diff -u -r1.2 Connection.java --- jdbc2/Connection.java 1999/05/18 23:17:26 1.2 +++ jdbc2/Connection.java 1999/06/01 16:03:52 @@ -311,7 +311,11 @@ */ public void setTransactionIsolation(int level) throws SQLException { - throw postgresql.Driver.notImplemented(); + if(level == java.sql.Connection.TRANSACTION_READ_COMMITTED) + ExecSQL("set transaction isolation level read commited"); + else if(level == java.sql.Connection.TRANSACTION_SERIALIZABLE) + ExecSQL("set transaction isolation level serializable"); + else throw postgresql.Driver.notImplemented(); } /** @@ -322,7 +326,9 @@ */ public int getTransactionIsolation() throws SQLException { - return java.sql.Connection.TRANSACTION_SERIALIZABLE; + ExecSQL("show transaction isolation level"); + + return isolationLevel; } /** Index: jdbc2/DatabaseMetaData.java =================================================================== RCS file: /usr/local/cvsroot/pgsql/src/interfaces/jdbc/postgresql/jdbc2/DatabaseMetaData.java,v retrieving revision 1.1 diff -u -r1.1 DatabaseMetaData.java --- jdbc2/DatabaseMetaData.java 1999/01/17 04:51:56 1.1 +++ jdbc2/DatabaseMetaData.java 1999/06/01 16:04:01 @@ -1350,7 +1350,7 @@ */ public int getDefaultTransactionIsolation() throws SQLException { - return Connection.TRANSACTION_SERIALIZABLE; + return Connection.TRANSACTION_READ_COMMITTED; } /** @@ -1378,6 +1378,8 @@ public boolean supportsTransactionIsolationLevel(int level) throws SQLException { if (level == Connection.TRANSACTION_SERIALIZABLE) + return true; + else if (level == Connection.TRANSACTION_READ_COMMITTED) return true; else return false;
^ permalink raw reply [nested|flat] 2+ messages in thread

* RE: [INTERFACES] Isolation level support with JDBC
@ 1999-06-03 10:20 Peter Mount <petermount@it.maidstone.gov.uk>
  0 siblings, 0 replies; 2+ messages in thread

From: Peter Mount @ 1999-06-03 10:20 UTC (permalink / raw)
  To: pgsql-interfaces; +Cc: Peter Mount (Home) <peter@retep.org.uk>

I'm slowly catching up with things, and I'll take a look at it later
tonight.

Peter

--
Peter T Mount, Enterprise Support
petermount@it.maidstone.gov.uk
Anything I write here are my own views, and cannot be taken as the
official words of Maidstone Borough Council


-----Original Message-----
From: Benoit Foucher [mailto:benoit@ooc.com]
Sent: Tuesday, June 01, 1999 5:09 PM
To: Postgres Interfaces
Subject: [INTERFACES] Isolation level support with JDBC


Hi,

Since two different transaction isolation levels are supported
with Postgres 6.5 (READ_COMMITED and SERIALIZABLE), I've added 
support for setting and getting isolation level with
the two methods java.sql.Connection.setTransactionIsolation and 
java.sql.Connection.getTransactionIsolation. 

I'd like to know if my  modifications are correct (I've never 
developped such stuff before) and if it could be added to the 
jdbc driver sources.

I've attached the patch to this mail.

Thank you!
Regards

Benoit.

-- 
Benoit Foucher
mailto:benoit@ooc.com



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~1999-06-03 10:20 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-06-01 16:08 Isolation level support with JDBC Benoit Foucher <benoit@ooc.com>
1999-06-03 10:20 RE: [INTERFACES] Isolation level support with JDBC Peter Mount <petermount@it.maidstone.gov.uk>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox