openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeremy Bauer (JIRA)" <>
Subject [jira] Updated: (OPENJPA-656) Incorrect connection URL causes NPE when using JDBC Driver
Date Thu, 10 Jul 2008 21:08:32 GMT


Jeremy Bauer updated OPENJPA-656:

    Attachment: OPENJPA-656.patch

Attaching patch with code fix and jUnits for 1.2.0/trunk.  Per the JDBC spec, "The driver
should return "null" if it realizes it is the wrong kind of driver to connect to the given
URL."  The most typical case for getting a null Connection is when the protocol or subprotocol
do not match what the driver expects. The fix checks for a null Connection being returned
by the driver in org.apache.openjpa.jdbc.schema.SimpleDriverDataSource.getConnection().  If
the Connection is null, a SQLException containing a detailed message is thrown.  

Please review and if no comments commit for 1.2.0.

> Incorrect connection URL causes NPE when using JDBC Driver
> ----------------------------------------------------------
>                 Key: OPENJPA-656
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.2.0
>            Reporter: Jeremy Bauer
>            Priority: Minor
>         Attachments: OPENJPA-656.patch
> If a JDBC URL is specified with an incorrect protocol or subprotocol in combination with
a JDBC Driver class when configuring a PU an NPE is thrown within the OpenJPA code when trying
to create an entity manager.  The NPE bubbles out to a not-so-useful PersistenceException
with internal StoreException containing message text "null".  
> For example:  (note the missing colon after the subprotocol)
> openjpa.ConnectionURL=jdbc:db2//  
> Results in:
>      [java] <openjpa-1.2.0-SNAPSHOT-r422266:667312 nonfatal general error> org.apache.openjpa.persistence.PersistenceException:
There were errors initializing your configuration: <openjpa-1.2.0-SNAPSHOT-r422266:667312
fatal store error> org.apache.openjpa.util.StoreException: null
>      [java]     at org.apache.openjpa.jdbc.schema.DataSourceFactory.installDBDictionary(
>      [java]     at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getConnectionFactory(
>      [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>      [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(
>      [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(
>      [java]     at java.lang.reflect.Method.invoke(
>      [java]     at org.apache.openjpa.lib.conf.ConfigurationImpl.instantiateAll(
>      [java]     at org.apache.openjpa.conf.OpenJPAConfigurationImpl.instantiateAll(
>      [java]     at org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(
>      [java]     at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(
>      [java]     at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(
>      [java]     at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(
>      [java]     at
>      [java]     at
>      [java]     at suite.r70.base.wasvadd.wsjpa_scripts.wsenhancer.VerifyEnhancementTest.main(
>      [java] Caused by: java.lang.NullPointerException
>      [java]     at org.apache.openjpa.lib.jdbc.DelegatingConnection.getAutoCommit(

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message