db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shreyas Kaushik (JIRA)" <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-95) NPE when passing in url instead of database name to EmbeddedXADataSource
Date Thu, 23 Dec 2004 09:54:09 GMT
     [ http://nagoya.apache.org/jira/browse/DERBY-95?page=comments#action_57006 ]
     
Shreyas Kaushik commented on DERBY-95:
--------------------------------------

The part of the code that causes this NPE to come up is in the setupResourceAdapter method
in the EmbeddedXADataSource.java, the fragment is here,

if (requestPassword) {
    getConnection(user, password).close();
}

Since the url passed is not a valid databaseName ( it considers the entire string as the database)
it cannot establish a connection so the call to getConnection() returns null and calling close
throws a NPE.

This can be resolved by checking if the connection handle returned by a call to the getConnection()
method is null or not. If it is not null do the processing that is currently happening( closing
of the connection in this case) , if it is null then throw a SQLException saying the database
doesn't exist.

The same case also needs to be taken care of in the code fragment following the above code
fragment as well.

> NPE when passing in url instead of database name to EmbeddedXADataSource
> ------------------------------------------------------------------------
>
>          Key: DERBY-95
>          URL: http://nagoya.apache.org/jira/browse/DERBY-95
>      Project: Derby
>         Type: Bug
>   Components: JDBC
>     Reporter: Myrna van Lunteren
>     Priority: Minor
>      Fix For: 10.0.2.1

>
> When passing in a url (e.g. jdbc:derby:mydb) instead of just the database name (e.g.
mydb) the XADataSource gives a NullPointerException.
> It should either handle this a little more gracefully & give an error, or accept
the url (like EmbeddedDataSource does).

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


Mime
View raw message