Bug #72632 NullPointerException for invalid JDBC URL
Submitted: 13 May 2014 15:21 Modified: 14 Sep 2016 22:46
Reporter: Olafur Egilsson Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:5.1.30 OS:Any
Assigned to: Filipe Silva CPU Architecture:Any
Tags: NullPointerException

[13 May 2014 15:21] Olafur Egilsson
Description:
If an invalid JDBC URL is used, then the Connector will crash with a NPE.

src/com/mysql/jdbc/jdbc2/optional/MysqlDataSource.java:429:
Properties urlProps = mysqlDriver.parseURL(jdbcUrlToUse, null);
urlProps.remove(NonRegisteringDriver.DBNAME_PROPERTY_KEY); // THIS WILL THROW NPE

How to repeat:
Set up a JDBC connection with invalid URL, like "${unparsed.placeholder}"

Suggested fix:
Throw a RuntimeException if urlProps is null after a call to parseUrl, with appropriate explanation.  The explanation should contain the URL which failed to parse.
[14 May 2014 9:15] Filipe Silva
Hi Olafur,

Thank you for this bug report. It was verified as described.
[14 Sep 2016 22:46] Daniel So
Posted by developer:
 
Added the following entry to the C/J 5.1.40 changelog:

"An invalid connection URL caused Connector/J to throw a NullPointerException. With this fix, an SQLException is thrown instead in the situation."
[14 Oct 2016 15:19] Daniel So
The fix has been included in Connector/J 6.0.5. The entry for the 5.1.40
changelog has been included into the 6.0.5 changelog.