openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r798945 - in /openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql: DB2Dictionary.java DBDictionary.java InformixDictionary.java
Date Wed, 29 Jul 2009 15:23:06 GMT
Author: mikedd
Date: Wed Jul 29 15:23:05 2009
New Revision: 798945

URL: http://svn.apache.org/viewvc?rev=798945&view=rev
Log:
OPENJPA-622:
Move check for isJDBC to DBDictionary class and prevent informix lock timeout
Submitted By : Jody Grassel based on Catalina's changes in trunk

Modified:
    openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
    openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java

Modified: openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=798945&r1=798944&r2=798945&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
(original)
+++ openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Wed Jul 29 15:23:05 2009
@@ -203,15 +203,6 @@
         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);
 
@@ -231,7 +222,7 @@
         }
         
     	if (db2ServerType == 0) {
-    	    if (isJDBC3(metaData)) {
+    	    if (isJDBC3) {
     	        maj = metaData.getDatabaseMajorVersion();
     	        min = metaData.getDatabaseMinorVersion();
     	    }

Modified: openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=798945&r1=798944&r2=798945&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Wed Jul 29 15:23:05 2009
@@ -143,7 +143,7 @@
     private static final String ZERO_TIMESTAMP_STR =
         "'" + new Timestamp(0) + "'";
 
-    private static final Localizer _loc = Localizer.forPackage
+    protected static final Localizer _loc = Localizer.forPackage
         (DBDictionary.class);
 
     // schema data
@@ -304,6 +304,7 @@
     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();
@@ -355,15 +356,30 @@
      */
     public void connectedConfiguration(Connection conn)
         throws SQLException {
-        if (!connected) {
+        DatabaseMetaData metaData = null;
+        try {
+            metaData = conn.getMetaData();
+            // JDBC3-only method, so it might throw a
+            // AbstractMethodError
             try {
-                if (log.isTraceEnabled())
-                    log.trace(DBDictionaryFactory.toString
-                        (conn.getMetaData()));
-            } catch (Exception e) {
-                log.trace(e.toString(), e);
+                isJDBC3 = metaData.getJDBCMajorVersion() >= 3;
+            } catch (Throwable t) {
+                // ignore if not JDBC3
             }
+        } catch (Exception 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[]{
+                        new Boolean(conn.getAutoCommit()), 
+                        new Integer(conn.getHoldability()),
+                        new Integer(conn.getTransactionIsolation())}));
         }
+        
         connected = true;
     }
 

Modified: openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java?rev=798945&r1=798944&r2=798945&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java
(original)
+++ openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java
Wed Jul 29 15:23:05 2009
@@ -122,7 +122,6 @@
         }));
 
         supportsQueryTimeout = false;
-        supportsMultipleNontransactionalResultSets = false;
         supportsLockingWithDistinctClause = false;
         supportsLockingWithMultipleTables = false;
         supportsLockingWithOrderClause = false;
@@ -148,6 +147,14 @@
             else
                 driverVendor = VENDOR_OTHER;
         }
+        if (isJDBC3) {
+            conn.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT);
+            if (log.isTraceEnabled())
+                log.trace(_loc.get("connection-defaults", new Object[]{
+                        new Boolean(conn.getAutoCommit()), 
+                        new Integer(conn.getHoldability()),
+                        new Integer(conn.getTransactionIsolation())}));
+        }
     }
 
     public Column[] getColumns(DatabaseMetaData meta, String catalog,



Mime
View raw message