OPENJPA-1351: fix ClassCastException when downlevel jdbc driver is used.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@825699 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Fay Wang 2009-10-15 23:32:44 +00:00
parent 6d50e87a03
commit 65d2ea8b19
2 changed files with 18 additions and 2 deletions

View File

@ -760,8 +760,22 @@ public class JDBCConfigurationImpl
public Object getConnectionFactory2() {
// override to configure data source
if (dataSource2 == null) {
// superclass will lookup from JNDI.
DataSource ds = (DataSource) super.getConnectionFactory2();
// superclass will lookup from JNDI.
Object obj = super.getConnectionFactory2();
DataSource ds = null;
if (obj != null) {
if (obj instanceof DataSource)
ds = (DataSource) obj;
else {
Log log = getLog(LOG_JDBC);
if (log.isTraceEnabled()) {
Localizer loc = Localizer.forPackage(JDBCConfigurationImpl.class);
log.trace(loc.get("unknown-datasource", getConnectionFactory2Name(),
obj.getClass().getName()));
}
}
}
if (ds == null) {
// the driver name is always required, so if not specified,
// then no connection factory 2

View File

@ -244,3 +244,5 @@ connecting-for-dictionary: OpenJPA will now connect to the database to attempt \
the documentation for available values).
map-factory: Using mapping factory "{0}".
meta-factory: Using metadata factory "{0}".
unknown-datasource: JNDI lookup for "{0}" returned "{1}", which is not a \
javax.sql.DataSource object.