openjpa-dev mailing list archives

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

     [ https://issues.apache.org/jira/browse/OPENJPA-656?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

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: https://issues.apache.org/jira/browse/OPENJPA-656
>             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.ConnectionDriverName=com.ibm.db2.jcc.DB2Driver
> openjpa.ConnectionURL=jdbc:db2//my.database.com:800/MYDB  
> 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(DataSourceFactory.java:240)
>      [java]     at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getConnectionFactory(JDBCConfigurationImpl.java:692)
>      [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>      [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
>      [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>      [java]     at java.lang.reflect.Method.invoke(Method.java:599)
>      [java]     at org.apache.openjpa.lib.conf.ConfigurationImpl.instantiateAll(ConfigurationImpl.java:288)
>      [java]     at org.apache.openjpa.conf.OpenJPAConfigurationImpl.instantiateAll(OpenJPAConfigurationImpl.java:1429)
>      [java]     at org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:646)
>      [java]     at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:183)
>      [java]     at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
>      [java]     at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
>      [java]     at com.ibm.ws.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:42)
>      [java]     at com.ibm.ws.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:27)
>      [java]     at suite.r70.base.wasvadd.wsjpa_scripts.wsenhancer.VerifyEnhancementTest.main(VerifyEnhancementTest.java:22)
>      [java] Caused by: java.lang.NullPointerException
>      [java]     at org.apache.openjpa.lib.jdbc.DelegatingConnection.getAutoCommit(DelegatingConnection.java:202)

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


Mime
View raw message