我想使用Java连接到我的MySQL数据库。使用Java连接到MySQL数据库
我正在使用JDBC,并且我安装了驱动程序。 (com.mysql.jdbc.Driver)
唯一的问题就是,我不断收到错误:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException The last packet sent successfully to the server was 0 milliseconds ago.
这里是我的代码:
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql:/mydomain.com/mydatabase", "username", "password");
我不积极如何组合URL(以及我的用户名和密码),但我做了大量的研究。
我是唯一一个访问我的数据库和域的人,所以没有必要询问管理员。
我使用phpMyAdmin来创建数据库并对其进行管理。我使用我的phpMyAdmin用户名和密码或什么?
顺便说一下,我的网站托管在Yahoo!小本生意。
所以我的问题是:
- 如何进行连接网址是什么?
- 我的用户名和密码是什么?
http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html –
到底在回答你的问题? – speedRS
[Java与MySQL的连接]可能的重复(http://stackoverflow.com/questions/2839321/java-connectivity-with-mysql) – Nekto