Cannot load connection class because of underlying exception: com.mysql.cj.core.exceptions.WrongArgumentException:Malformed database URL, failed to parse the main URL sections.

3,678 views
Skip to first unread message

Chandrakanth K

unread,
Jul 2, 2018, 1:28:12 PM7/2/18
to H2 Database


  val JDBC_DRIVER = "org.h2.Driver"
  val DB_URL = "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"
  val USER = "sa"
  val PASS = ""
  Class.forName(JDBC_DRIVER)
conn = DriverManager.getConnection(DB_URL, USER, PASS)


 The above method is creating the exception  "Cannot load connection class because of underlying exception: com.mysql.cj.core.exceptions.WrongArgumentException:Malformed database URL, failed to parse the main URL sections."

I dont understand why it is trying to connecting to mysql 

Has anyone faced similar issue?

How do i solve it?

Evgenij Ryazanov

unread,
Jul 4, 2018, 11:45:43 PM7/4/18
to H2 Database
Hello.

This problem is not related with H2, but related with broken MySQL driver that is also included in your classpath. DriverManager does not map URLs to drivers by itself, it probes all registered drivers instead. Some versions of MySQL driver incorrectly throw similar exceptions instead of returning null to indicate that specified URL is not suitable for them. Use different version of MySQL driver or remove it form your classpath if you don't need it in your application.

Reply all
Reply to author
Forward
0 new messages