Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id F042563282D for ; Sun, 11 Apr 2010 00:39:41 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 80548-05 for ; Sun, 11 Apr 2010 03:39:31 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-gw0-f46.google.com (mail-gw0-f46.google.com [74.125.83.46]) by mail.postgresql.org (Postfix) with ESMTP id 72473632661 for ; Sun, 11 Apr 2010 00:39:31 -0300 (ADT) Received: by gwj19 with SMTP id 19so430355gwj.19 for ; Sat, 10 Apr 2010 20:39:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:x-enigmail-version:content-type :content-transfer-encoding; bh=3jqK+tLQqBj+4wHXh9rbrhKP5tsn6s9VSuK4Iwon+gc=; b=DbM35IgiBV69jq5jKl/S7nDsZtZABvu2Bz1artP9JbxTViq44h/PORAdmhHUQDJrYd oWDjWRET097gaTCt/R20JM5K/rYn/6CKbdElFm6jFNrZPzIzvw/ctIwEdzwydoKzv9qQ 14gX37ioApBLRBZVTyFOD0fSaorNXWz5FZ8jI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :x-enigmail-version:content-type:content-transfer-encoding; b=PKB9hGMpiy9DOInmYxmFHG/Lbd5+GE21Hq8AaX8gsA097iF7GGZABLKnMWlfNzXWRl 2+2lTHiGVgWo1WeGP6v8VxNfRR0TlWSv5+mFzMt6OCahISpbyGFPlfFMohVcGUtdEN2r o1uNnSEHidp+hPveMNyFw0N7PbnLLI2vJsVtQ= Received: by 10.150.94.6 with SMTP id r6mr1988443ybb.306.1270957170842; Sat, 10 Apr 2010 20:39:30 -0700 (PDT) Received: from [192.168.1.100] ([190.177.74.211]) by mx.google.com with ESMTPS id 8sm730930yxg.13.2010.04.10.20.39.29 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 10 Apr 2010 20:39:30 -0700 (PDT) Message-ID: <4BC144D3.4030808@gmail.com> Date: Sun, 11 Apr 2010 00:41:07 -0300 From: Ader Javier User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: It is safe remenber current Isolation level in AbstractJdbc2Connection? X-Enigmail-Version: 0.96.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.011 tagged_above=-10 required=5 tests=FREEMAIL_FROM=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201004/16 X-Sequence-Number: 20427 Hi and sorry by my English. I have a software that checks the Isolation level before create "every" PreparedStatement over a Connection (there is a pool of connections from we pick one). Some like this: if( connection.getTransactionIsolation() != Connection.TRANSACTION_READ_COMMITTED ) { connection.setTransactionIsolation( Connection.TRANSACTION_READ_COMMITTED ); } .... PreparedStatement stmt = connection.createPreparedStatement(....) return stmt; My problem is that AbstractJdbc2Connection.getTransactionIsolation() access the server ever and don't remember the last level used, so It's safe change getTransactionIsolation() and setTransactionIsolation(level) for avoid unnecessary access? That's my idea public abstract class AbstractJdbc2Connection implements BaseConnection { .... //cached Isolation level private Integer level = null; .... public int getTransactionIsolation() throws SQLException { checkClosed(); //new : avoid access if there is one previous if (this.level != null) return this.level.intValue(); .... .... level = level.toUpperCase(Locale.US); // mod: caching before return return if (level.indexOf("READ COMMITTED") != -1) this.level = new Integer(Connection.TRANSACTION_READ_COMMITTED); if (level.indexOf("READ UNCOMMITTED") != -1) this.level= new Integer(Connection.TRANSACTION_READ_UNCOMMITTED); if (level.indexOf("REPEATABLE READ") != -1) this.level = new Integer(Connection.TRANSACTION_REPEATABLE_READ) if (level.indexOf("SERIALIZABLE") != -1) this.level = new Integer(Connection.TRANSACTION_SERIALIZABLE); if (this.level != null) return this.level.valueInt(); this.level = new Integer(Connection.TRANSACTION_READ_COMMITTED); // Best guess return this.level.valueInt(); } public void setTransactionIsolation(int level) throws SQLException { ... //new: caching before return this.level = new Integer(level); } By the way, property "read only" is managed in this way (see AbstractJdbc2Connection.getReadOnly() and AbstractJdbc2Connection.setReadOnly(boolean). Thanks! Ader Javier