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 dcf0f4663..66c3a121d 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 @@ -274,16 +274,21 @@ public class DB2Dictionary super.connectedConfiguration(conn); DatabaseMetaData metaData = conn.getMetaData(); - 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()); + try { + String str = "SELECT CURRENT SCHEMA FROM SYSIBM.SYSDUMMY1"; + 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(); + } catch (SQLException e) { + if (log.isTraceEnabled()) + log.trace(_loc.get("can_not_get_current_schema", e.getMessage())); } - rs.close(); - stmnt.close(); String driverName = metaData.getDriverName(); if (driverName != null && driverName.startsWith("IBM DB2")) diff --git a/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties b/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties index 05c292075..6ae28b91a 100644 --- a/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties +++ b/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties @@ -204,3 +204,4 @@ cannot-determine-identifier-case: Unable to determine the case to use for delimi identifiers. The default value of "preserve" will be used. unknown-delim-support: Unable to determine whether delimited identifiers are supported. \ The use of delimiters will not be supported. +can_not_get_current_schema: Unable to get current schema. SQLException message is "{0}". \ No newline at end of file