java - Unable to connect to mysql jdbc database -
i frustrated seeing error , not knowing solution. trying connect mysql db server url giving mysqlexception(stacktrace below). code works fine till here:
string dburl = "jdbc:mysql://server_url/db_name"; string driver = "com.mysql.jdbc.driver"; class.forname(driver).newinstance(); string user = "user"; string password = "password"; conn = drivermanager.getconnection(dburl,user,password);
this error i'm getting
java.sql.sqlexception: null, message server: "host '172.23.251.154' not allowed connect mysql server" @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:946) @ com.mysql.jdbc.mysqlio.dohandshake(mysqlio.java:1070) @ 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:582) @ java.sql.drivermanager.getconnection(drivermanager.java:185)
is because i'm using different version of mysql-connector jar? please help me.
from chapter 6. sql questions: how enable tcp connections mysql?,
by default, mysql won't allow users access of databases if connect on tcp
connection. in order permit connection, must create entry in user
table of mysql
database (make sure select password
function encrypt password). in particular, host
field needs indicate host(s) permitted connect. if specify %
(which not recommend), user able connect host.
java mysql database jdbc
No comments:
Post a Comment