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
This commit is contained in:
Kevin W. Sutter 2007-10-29 16:23:17 +00:00
parent 80d2c39020
commit 2f2e39991d
2 changed files with 20 additions and 2 deletions

View File

@ -189,6 +189,7 @@ public class DataSourceFactory {
DataSource inner = ds.getInnermostDelegate(); DataSource inner = ds.getInnermostDelegate();
if (inner instanceof DriverDataSource) if (inner instanceof DriverDataSource)
((DriverDataSource) inner).initDBDictionary(dict); ((DriverDataSource) inner).initDBDictionary(dict);
Connection conn = null;
try { try {
// add the dictionary as a warning handler on the logging // 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 // allow the dbdictionary to decorate the connection further
ds.addDecorator(dict); 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; return ds;
} catch (Exception e) { } catch (Exception e) {
throw new StoreException(e).setFatal(true); 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
}
} }
} }

View File

@ -238,8 +238,8 @@ ConnectionURL-values: jdbc:JSQLConnect://<hostname>/database=<database>,\
jdbc:dbaw://<hostname>:8889/<database> jdbc:dbaw://<hostname>:8889/<database>
connecting-for-dictionary: OpenJPA will now connect to the database to attempt \ connecting-for-dictionary: OpenJPA will now connect to the database to attempt \
to determine what type of database dictionary to use. To prevent this \ to determine what type of database dictionary to use. You may prevent this \
connection in the future, set your openjpa.jdbc.DBDictionary \ connection in the future by setting your openjpa.jdbc.DBDictionary \
configuration property to the appropriate value for your database (see \ configuration property to the appropriate value for your database (see \
the documentation for available values). the documentation for available values).
map-factory: Using mapping factory "{0}". map-factory: Using mapping factory "{0}".