From b08a0d179bb3fd690da18a2556e9ccc09dfb2c0a Mon Sep 17 00:00:00 2001 From: Fay Wang Date: Thu, 21 Jan 2010 17:03:33 +0000 Subject: [PATCH] OPENJPA-1455: VALUES CURRENT SCHEMA fails in DB2 on zOS. Change the SQL to SELECT CURRENT SCHEMA FROM SYSIBM.SYSDUMMY1. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@901775 13f79535-47bb-0310-9956-ffa450edef68 --- .../openjpa/jdbc/sql/DB2Dictionary.java | 23 +++++++++++-------- .../openjpa/jdbc/sql/localizer.properties | 1 + 2 files changed, 15 insertions(+), 9 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 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