From 8a80d753a31e71ce07f24e7069b7ff5e71e30c03 Mon Sep 17 00:00:00 2001 From: Catalina Wei Date: Wed, 4 Jun 2008 19:49:41 +0000 Subject: [PATCH] OPENJPA-622 Informix -lock timieout, cursor not open problem for NonJTA datasource transaction RESOURCE_LOCAL in JEE git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@663358 13f79535-47bb-0310-9956-ffa450edef68 --- .../openjpa/jdbc/sql/DB2Dictionary.java | 11 +----- .../apache/openjpa/jdbc/sql/DBDictionary.java | 38 ++++++++++--------- .../openjpa/jdbc/sql/InformixDictionary.java | 8 +++- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java index ea64aaa0e..bb90aedb4 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java @@ -238,15 +238,6 @@ public class DB2Dictionary return conn; } - private boolean isJDBC3(DatabaseMetaData meta) { - try { - // JDBC3-only method, so it might throw a AbstractMethodError - return meta.getJDBCMajorVersion() >= 3; - } catch (Throwable t) { - return false; - } - } - public void connectedConfiguration(Connection conn) throws SQLException { super.connectedConfiguration(conn); @@ -266,7 +257,7 @@ public class DB2Dictionary } if (db2ServerType == 0) { - if (isJDBC3(metaData)) { + if (isJDBC3) { maj = metaData.getDatabaseMajorVersion(); min = metaData.getDatabaseMinorVersion(); } diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java index a5e09e94a..624aedb90 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java @@ -327,6 +327,7 @@ public class DBDictionary protected JDBCConfiguration conf = null; protected Log log = null; protected boolean connected = false; + protected boolean isJDBC3 = false; protected final Set reservedWordSet = new HashSet(); protected final Set systemSchemaSet = new HashSet(); protected final Set systemTableSet = new HashSet(); @@ -374,27 +375,28 @@ public class DBDictionary public void connectedConfiguration(Connection conn) throws SQLException { if (!connected) { - DatabaseMetaData metaData = null; + DatabaseMetaData metaData = null; try { - if (log.isTraceEnabled()) { - metaData = conn.getMetaData(); - boolean isJDBC3 = false; - log.trace(DBDictionaryFactory.toString - (metaData)); - try { - // JDBC3-only method, so it might throw a - // AbstractMethodError - isJDBC3 = metaData.getJDBCMajorVersion() >= 3; - } catch (Throwable t) { - // ignore if not JDBC3 - } - if (isJDBC3) - log.trace(_loc.get("connection-defaults", new Object[]{ - conn.getAutoCommit(), conn.getHoldability(), - conn.getTransactionIsolation()})); + metaData = conn.getMetaData(); + try { + // JDBC3-only method, so it might throw a + // AbstractMethodError + isJDBC3 = metaData.getJDBCMajorVersion() >= 3; + } catch (Throwable t) { + // ignore if not JDBC3 } } catch (Exception e) { - log.trace(e.toString(), e); + if (log.isTraceEnabled()) + log.trace(e.toString(), e); + } + + if (log.isTraceEnabled()) { + log.trace(DBDictionaryFactory.toString(metaData)); + + if (isJDBC3) + log.trace(_loc.get("connection-defaults", new Object[]{ + conn.getAutoCommit(), conn.getHoldability(), + conn.getTransactionIsolation()})); } } connected = true; diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java index 193730087..79e9e6eb2 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java @@ -121,7 +121,6 @@ public class InformixDictionary })); supportsQueryTimeout = false; - supportsMultipleNontransactionalResultSets = false; supportsLockingWithDistinctClause = false; supportsLockingWithMultipleTables = false; supportsLockingWithOrderClause = false; @@ -161,6 +160,13 @@ public class InformixDictionary else driverVendor = VENDOR_OTHER; } + if (isJDBC3) { + conn.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT); + if (log.isTraceEnabled()) + log.trace(_loc.get("connection-defaults", new Object[]{ + conn.getAutoCommit(), conn.getHoldability(), + conn.getTransactionIsolation()})); + } } public Column[] getColumns(DatabaseMetaData meta, String catalog,