From e53378bd2697a023a2be5d4c9191fa80c3411800 Mon Sep 17 00:00:00 2001 From: Fay Wang Date: Mon, 11 Jan 2010 23:43:38 +0000 Subject: [PATCH] OPENJPA-1455: fix the way to get current schema per Milosz's suggestion. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@898118 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/openjpa/jdbc/sql/DB2Dictionary.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 9032b5538..e2af98907 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 @@ -26,6 +26,7 @@ import java.sql.DatabaseMetaData; 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 @@ public class DB2Dictionary 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;