Reputation: 11
I'm trying to establish an SSL connection from java application to mysql server. Following are the setup details.
But when I try to connect through the java application, following exception is thrown.
Caused by: com.mysql.cj.exceptions.WrongArgumentException: Malformed database URL, failed to parse the connection string near '=true&requireSSL=true'.
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.exceptions.ExceptionFactory.createException(ExceptionFactory.java:59)
at com.mysql.cj.conf.ConnectionUrlParser.processKeyValuePattern(ConnectionUrlParser.java:524)
at com.mysql.cj.conf.ConnectionUrlParser.parseQuerySection(ConnectionUrlParser.java:496)
at com.mysql.cj.conf.ConnectionUrlParser.getProperties(ConnectionUrlParser.java:621)
at com.mysql.cj.conf.ConnectionUrl.collectProperties(ConnectionUrl.java:302)
at com.mysql.cj.conf.ConnectionUrl.<init>(ConnectionUrl.java:287)
at com.mysql.cj.conf.url.SingleConnectionUrl.<init>(SingleConnectionUrl.java:47)
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.util.Util.handleNewInstance(Util.java:210)
at com.mysql.cj.util.Util.getInstance(Util.java:185)
at com.mysql.cj.util.Util.getInstance(Util.java:192)
at com.mysql.cj.conf.ConnectionUrl.getConnectionUrlInstance(ConnectionUrl.java:189)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:201)
... 83 more
Upvotes: 0
Views: 387
Reputation: 909
Try changing your connection url to
jdbc:mysql://localhost:3306/carbon_mysql?autoReconnect=true&useSSL=true&requireSSL=true&verifyServerCertificate=true
You also have to make sure that you have granted ssl on mysql. log in as root in the MySQL server, and run the queries given below:
GRANT USAGE ON *.* TO 'root'@'%' REQUIRE SSL;
FLUSH PRIVILEGES;
Upvotes: 0