Return-Path: X-Original-To: apmail-db-derby-dev-archive@www.apache.org Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B9637EF93 for ; Wed, 27 Feb 2013 04:44:16 +0000 (UTC) Received: (qmail 38815 invoked by uid 500); 27 Feb 2013 04:44:16 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 38617 invoked by uid 500); 27 Feb 2013 04:44:15 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 38576 invoked by uid 99); 27 Feb 2013 04:44:14 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Feb 2013 04:44:14 +0000 Date: Wed, 27 Feb 2013 04:44:14 +0000 (UTC) From: "Mamta A. Satoor (JIRA)" To: derby-dev@db.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (DERBY-6053) Client should use a prepared statement rather than regular statement for Connection.setTransactionIsolation MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DERBY-6053?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13587994#comment-13587994 ] Mamta A. Satoor commented on DERBY-6053: ---------------------------------------- I am working on backporting the 2 commits that went in for this jira into 10.9 codelines. But the declaration of isolationLevelPreparedStmts includes type parameters as shown below final private HashMap isolationLevelPreparedStmts = new HashMap(); This code when compiled in 10.9 gives following compile time error [javac] C:\p4clients\svn10.9\client1\10.9\java\client\org\apache\derby\client\am\Connection.java:91: generics are not supported in -source 1.4 [javac] (use -source 5 or higher to enable generics) [javac] final private HashMap [javac] ^ I know there are other clases in 10.9 that include type parameters during HashMap declaration eg org.apache.derby.iapi.jdbc.FailedProperties40 but build.xml has been modified to compile them with compilerLevel16 rather than 1.4. Is it ok to solve the compile time issue with Connection.java by having it compile with compilerLevel16 or should I use the old style HashMap declaration(without the type parameters) which is found scattered around in 10.9 codeline? Thanks for the help. > Client should use a prepared statement rather than regular statement for Connection.setTransactionIsolation > ----------------------------------------------------------------------------------------------------------- > > Key: DERBY-6053 > URL: https://issues.apache.org/jira/browse/DERBY-6053 > Project: Derby > Issue Type: Improvement > Components: Network Client > Reporter: Kathey Marsden > Assignee: Mamta A. Satoor > Fix For: 10.10.0.0 > > Attachments: derby-6053-01-aa-lintCheck.diff, DERBY6053_patch1_diff.txt > > > o.a.d.client.am.Connection setTransactionIsolation() uses a Statement which it builds up each time for setTransactionIsolation() is called. > private Statement setTransactionIsolationStmt = null; > ... > setTransactionIsolationStmt = > createStatementX(java.sql.ResultSet.TYPE_FORWARD_ONLY, > java.sql.ResultSet.CONCUR_READ_ONLY, > holdability()); > .... > private void setTransactionIsolationX(int level) > ... > setTransactionIsolationStmt.executeUpdate( > "SET CURRENT ISOLATION = " + levelString); > It would be better for performance and also for avoid possible garbage collection issues, to have a single prepared statement with a parameter marker. > The program below shows repeated calls to setTransactionIsolation. > import java.sql.*; > import java.net.*; > import java.io.*; > import org.apache.derby.drda.NetworkServerControl; > /** > * Client template starts its own NetworkServer and runs some SQL against it. > * The SQL or JDBC API calls can be modified to reproduce issues > * > */public class SetTransactionIsolation { > public static Statement s; > > public static void main(String[] args) throws Exception { > try { > // Load the driver. Not needed for network server. > > Class.forName("org.apache.derby.jdbc.ClientDriver"); > // Start Network Server > startNetworkServer(); > // If connecting to a customer database. Change the URL > Connection conn = DriverManager > .getConnection("jdbc:derby://localhost:1527/wombat;create=true"); > // clean up from a previous run > s = conn.createStatement(); > try { > s.executeUpdate("DROP TABLE T"); > } catch (SQLException se) { > if (!se.getSQLState().equals("42Y55")) > throw se; > } > for (int i = 0; i < 50000; i++) { > conn.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); > conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); > } > > // rs.close(); > // ps.close(); > runtimeInfo(); > conn.close(); > // Shutdown the server > shutdownServer(); > } catch (SQLException se) { > while (se != null) { > System.out.println("SQLState=" + se.getSQLState() > + se.getMessage()); > se.printStackTrace(); > se = se.getNextException(); > } > } > } > > /** > * starts the Network server > * > */ > public static void startNetworkServer() throws SQLException { > Exception failException = null; > try { > > NetworkServerControl networkServer = new NetworkServerControl( > InetAddress.getByName("localhost"), 1527); > > networkServer.start(new PrintWriter(System.out)); > > // Wait for the network server to start > boolean started = false; > int retries = 10; // Max retries = max seconds to wait > > while (!started && retries > 0) { > try { > // Sleep 1 second and then ping the network server > Thread.sleep(1000); > networkServer.ping(); > > // If ping does not throw an exception the server has > // started > started = true; > } catch (Exception e) { > retries--; > failException = e; > } > > } > > // Check if we got a reply on ping > if (!started) { > throw failException; > } > } catch (Exception e) { > SQLException se = new SQLException("Error starting network server"); > se.initCause(failException); > throw se; > } > } > > public static void shutdownServer() throws Exception { > NetworkServerControl networkServer = new NetworkServerControl( > InetAddress.getByName("localhost"), 1527); > networkServer.shutdown(); > } > > public static void runtimeInfo() throws Exception { > NetworkServerControl networkServer = new NetworkServerControl( > InetAddress.getByName("localhost"), 1527); > System.out.println(networkServer.getRuntimeInfo()); > } > > } -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira