openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fayw...@apache.org
Subject svn commit: r898118 - /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Date Mon, 11 Jan 2010 23:43:38 GMT
Author: faywang
Date: Mon Jan 11 23:43:38 2010
New Revision: 898118

URL: http://svn.apache.org/viewvc?rev=898118&view=rev
Log:
OPENJPA-1455: fix the way to get current schema per Milosz's suggestion.

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=898118&r1=898117&r2=898118&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Mon Jan 11 23:43:38 2010
@@ -26,6 +26,7 @@
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.sql.Types;
 import java.util.Arrays;
 import java.util.EnumSet;
@@ -266,7 +267,17 @@
         super.connectedConfiguration(conn);
 
         DatabaseMetaData metaData = conn.getMetaData();
-        setDefaultSchemaName(metaData.getUserName());
+        String str = "VALUES CURRENT SCHEMA";
+        Statement stmnt = conn.createStatement();
+        ResultSet rs = stmnt.executeQuery(str);
+        if (rs.next()) {
+            String currSchema = rs.getString(1);
+            if (currSchema != null)
+                setDefaultSchemaName(currSchema.trim());
+        }
+        rs.close();
+        stmnt.close();
+
         String driverName = metaData.getDriverName();
         if (driverName != null && driverName.startsWith("IBM DB2"))
             driverVendor = VENDOR_IBM;



Mime
View raw message