Connecting to MySql using Java - SSL Connection -


i have been trying to connect mysql data base uses ssl connection java , having trouble, if 1 can me of great help.

manual connection mysql:

we use mysql workbench , parameters - hostname - "test-db1-ro-xxxxxx.net" , port - 3306 , user name , password. there ssl ca file - mysql-ssl-ca-cert.pem , manual connection successful.

i tried same in java (in windows system) code:

string url = "jdbc:mysql://test-db1-ro.apdev.xxxxxx.net:3306/database"; string driver = "com.mysql.jdbc.driver";  string username = "xxxxxxxx";  string password = "xxxxxxxx"; class.forname(driver).newinstance(); connection conn = drivermanager.getconnection(url,username,password); 

when run code error "access denied" thinking due ssl connection.

i not able know how use .pem file make secure connection database in case.

can 1 help, have done various things same access denied error.

full stacktrace:

java.sql.sqlexception: access denied user 'xxxxxxxx' (using password: yes)     @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:946)     @ com.mysql.jdbc.mysqlio.checkerrorpacket(mysqlio.java:2985)     @ com.mysql.jdbc.mysqlio.checkerrorpacket(mysqlio.java:885)     @ com.mysql.jdbc.mysqlio.secureauth411(mysqlio.java:3421)     @ com.mysql.jdbc.mysqlio.dohandshake(mysqlio.java:1247)     @ com.mysql.jdbc.connection.createnewio(connection.java:2775)     @ com.mysql.jdbc.connection.<init>(connection.java:1555)     @ com.mysql.jdbc.nonregisteringdriver.connect(nonregisteringdriver.java:285)     @ java.sql.drivermanager.getconnection(drivermanager.java:571)     @ java.sql.drivermanager.getconnection(drivermanager.java:215)     @ testdbconnection.main(testdbconnection.java:34) 

you have trouble authenticating.
on mysql terminal:

grant on *.* 'user'@'%' identified 'password'; flush privileges; 

if problem still persists:

grant on *.* 'user'@'%' grant option; 

this command grants superuser privileges.

flush privileges; 

to make sure privileges loaded.

nb: not use account on websites public access.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -