From 2f2e39991d5c6485183d03c3d1051f4fb5ce0ee9 Mon Sep 17 00:00:00 2001 From: "Kevin W. Sutter" Date: Mon, 29 Oct 2007 16:23:17 +0000 Subject: [PATCH] OPENJPA-421. Committing Daniel's changes to ensure that the datasource configuration is complete before attempting to generate SQL. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@589723 13f79535-47bb-0310-9956-ffa450edef68 --- .../openjpa/jdbc/schema/DataSourceFactory.java | 18 ++++++++++++++++++ .../openjpa/jdbc/conf/localizer.properties | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java index 8db475103..560c15dfd 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java @@ -189,6 +189,7 @@ public class DataSourceFactory { DataSource inner = ds.getInnermostDelegate(); if (inner instanceof DriverDataSource) ((DriverDataSource) inner).initDBDictionary(dict); + Connection conn = null; try { // add the dictionary as a warning handler on the logging @@ -219,9 +220,26 @@ public class DataSourceFactory { // allow the dbdictionary to decorate the connection further ds.addDecorator(dict); + + // ensure dbdictionary to process connectedConfiguration() + if (!factory2) + conn = ds.getConnection(conf.getConnectionUserName(), conf + .getConnectionPassword()); + else + conn = ds.getConnection(conf.getConnection2UserName(), conf + .getConnection2Password()); + return ds; } catch (Exception e) { throw new StoreException(e).setFatal(true); + } finally { + if (conn != null) + try { + conn.close(); + } catch (SQLException se) { + // ignore any exception since the connection is not going + // to be used anyway + } } } diff --git a/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/conf/localizer.properties b/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/conf/localizer.properties index 26be53c72..d48c00946 100644 --- a/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/conf/localizer.properties +++ b/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/conf/localizer.properties @@ -238,8 +238,8 @@ ConnectionURL-values: jdbc:JSQLConnect:///database=,\ jdbc:dbaw://:8889/ connecting-for-dictionary: OpenJPA will now connect to the database to attempt \ - to determine what type of database dictionary to use. To prevent this \ - connection in the future, set your openjpa.jdbc.DBDictionary \ + to determine what type of database dictionary to use. You may prevent this \ + connection in the future by setting your openjpa.jdbc.DBDictionary \ configuration property to the appropriate value for your database (see \ the documentation for available values). map-factory: Using mapping factory "{0}".