Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将PHPMyAdmin MySQL连接配置转换为JDBC_Java_Php_Mysql_Jdbc_Blowfish - Fatal编程技术网

Java 将PHPMyAdmin MySQL连接配置转换为JDBC

Java 将PHPMyAdmin MySQL连接配置转换为JDBC,java,php,mysql,jdbc,blowfish,Java,Php,Mysql,Jdbc,Blowfish,我让PHPMyAdmin使用以下参数连接到远程MySQL服务器: $cfg['blowfish_secret'] = 'ba17c1ec07d65003'; /* Authentication type */ $cfg['Servers'][$i]['auth_type'] = 'cookie'; /* Server parameters */ $cfg['Servers'][$i]['host'] = '*remoteServer*:3306'; $cfg['Servers'][$i]['ex

我让PHPMyAdmin使用以下参数连接到远程MySQL服务器:

$cfg['blowfish_secret'] = 'ba17c1ec07d65003';
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = '*remoteServer*:3306';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['controluser'] = '*user*';
$cfg['Servers'][$i]['controlpass'] = '*password*';
我正在尝试用Java连接到这个MySQL服务器,这两个都不起作用:

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

final String url ="jdbc:mysql://*remoteServer*/*user*";
Connection conn = DriverManager.getConnection(url, "*user*", "*password*");
我得到了这个错误:

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)
    ...
我认为它来自于“河豚鱼的秘密”(这只是一个随机的cookie)和“auth_type”=“cookie”在Java中没有被考虑

我该如何解决这个问题


另外,我是否需要告诉MySQL,他必须接受与jdbc驱动程序的对话?(如果是,我就完蛋了,我没有访问MySQL配置文件的权限)

blowfish_secret和auth_type仅作为phpmyadmin软件的一部分使用,它们与MySQL连接无关


您是否拥有允许从运行java的机器访问MySQL的防火墙,以及是否设置了从特定主机访问该用户的权限?

blowfish_secret和auth_type仅用作phpmyadmin软件的一部分,它们与MySQL连接无关


您是否有允许从运行java的机器访问MySQL的防火墙?您是否设置了从该特定主机访问该用户的权限?

谢谢!我认为授权是可以的:运行PHPMyAdmin的机器也运行java,PHPMyAdmin连接到MySQL没有问题。你认为PHPMyAdmin会一直保持与该用户的连接吗?当我没有登录时,它会发生事件吗?PHP应用程序不像java,连接是根据每个请求建立的。如果您使用相同的用户/密码组合在同一台计算机上进行连接,那么它应该可以工作。您可能想看看phpMyAdmin的配置选项在这里是什么意思:好的。因此,问题似乎在别处。可能是一些坏的jdbc驱动程序,java端的连接问题,或者MySQL中的一些配置。无论如何,我认为导出数据库并将其安装在前端服务器上就可以了。谢谢你的帮助!谢谢我认为授权是可以的:运行PHPMyAdmin的机器也运行java,PHPMyAdmin连接到MySQL没有问题。你认为PHPMyAdmin会一直保持与该用户的连接吗?当我没有登录时,它会发生事件吗?PHP应用程序不像java,连接是根据每个请求建立的。如果您使用相同的用户/密码组合在同一台计算机上进行连接,那么它应该可以工作。您可能想看看phpMyAdmin的配置选项在这里是什么意思:好的。因此,问题似乎在别处。可能是一些坏的jdbc驱动程序,java端的连接问题,或者MySQL中的一些配置。无论如何,我认为导出数据库并将其安装在前端服务器上就可以了。谢谢你的帮助!