开发者

Translating PHPMyAdmin MySQL connection configuration to JDBC

I have PHPMyAdmin connecting to a remote MySQL server, using those parameters:

$cfg['blowfish_secret'] = 'ba17c1ec07d65003';
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server par开发者_开发百科ameters */
$cfg['Servers'][$i]['host'] = '*remoteServer*:3306';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['controluser'] = '*user*';
$cfg['Servers'][$i]['controlpass'] = '*password*';

I'm trying to connect to this MySQL server in Java, neither of those work:

final String url ="jdbc:mysql://*remoteServer*:3306/*user*";
Connection conn = DriverManager.getConnection(url, "*user*", "*password*");

and, with ":3306" removed :

final String url ="jdbc:mysql://*remoteServer*/*user*";
Connection conn = DriverManager.getConnection(url, "*user*", "*password*");

I'm getting this error:

SQLException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago.
The driver has not received any packets from the server.
SQLState:     08S01
VendorError:  0
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago.
The driver has not received any packets from the server.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    ...

I think it comes from the "blowfish_secret" (which is just a random cookie) and "auth_type"="cookie" not being accounted for in Java.

How do I fix this?

Also, do I need to tell MySQL that he has to accept to talk to the jdbc driver? (if yes, I'm screwed, I don't have access to the MySQL config files)


blowfish_secret and auth_type are used only as part of the phpmyadmin software, they have nothing to do with a mysql connection.

Do you have firewalls allowing access to MySQL from the machine running java and do you have grants set up to access that user from that specific host?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜