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
This commit is contained in:
Fay Wang 2010-01-11 23:43:38 +00:00
parent 0efea474f2
commit e53378bd26
1 changed files with 12 additions and 1 deletions

View File

@ -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;