Bug #87600 Connector throws 'Malformed database URL' on non mysql connection-urls
Description:
When trying to connect to an oracle database, and the mysql-connector is also in classpath, it throws a 'Malformed database URL' while the 'DriverManager.getConnection' probes the different drivers.
The connection URL for oracle is 'jdbc:oracle:thin:@127.0.0.1:1521:xe' - which is unparseable for mysql.
(Similar to https://bugs.mysql.com/bug.php?id=82896)
How to repeat:
Testcode:
conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:xe", "user", "pass");
Expected behaviour:
- Connect successfully (if oracle driver is in classpath)
- Get "No suitable driver found" - if driver is not in classpath
Current behaviour:
- mysql-connector fails with "Malformed database URL" and makes it impossible to connect to oracle db
Workaround:
- use version 5.1.43
Stack Trace:
java.sql.SQLNonTransientConnectionException: Cannot load connection class because of underlying exception: com.mysql.cj.core.exceptions.WrongArgumentException: Malformed database URL, failed to parse the main URL sections.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:526)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:513)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:505)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:479)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:489)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:72)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:124)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:224)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at io.ebean.TestBase.main(TestBase.java:11)
Caused by: com.mysql.cj.core.exceptions.UnableToConnectException: Cannot load connection class because of underlying exception: com.mysql.cj.core.exceptions.WrongArgumentException: Malformed database URL, failed to parse the main URL sections.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.cj.core.exceptions.ExceptionFactory.createException(ExceptionFactory.java:54)
at com.mysql.cj.core.exceptions.ExceptionFactory.createException(ExceptionFactory.java:93)
... 4 more
Caused by: com.mysql.cj.core.exceptions.WrongArgumentException: Malformed database URL, failed to parse the main URL sections.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.cj.core.exceptions.ExceptionFactory.createException(ExceptionFactory.java:54)
at com.mysql.cj.core.conf.url.ConnectionUrlParser.parseConnectionString(ConnectionUrlParser.java:134)
at com.mysql.cj.core.conf.url.ConnectionUrlParser.<init>(ConnectionUrlParser.java:124)
at com.mysql.cj.core.conf.url.ConnectionUrlParser.parseConnectionString(ConnectionUrlParser.java:113)
at com.mysql.cj.core.conf.url.ConnectionUrl.getConnectionUrlInstance(ConnectionUrl.java:192)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:194)
... 3 more
Suggested fix:
NonRegisteredDriver.connect should not try to parse other driver's urls and return "null" immediately, if url does not start with "jdbc:mysql:" (Normal jdbc connection) or "mysqlx:" (XDEVAPI_SESSION)
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.054 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.