好吧,我不再使用 XAMPP,现在我通过网络主机托管我的 hiscores,我该如何编辑这一行,以便它可以使用它,当我运行服务器时,它会抛出错误。
public static void createConnection() {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection(
"jdbc:mysql://fdb4.awardspace.com/", "1191306_hiscores", "passremoved");
stmt = con.createStatement();
Misc.println("Connected");
} catch (Exception e) {
Misc.println("Connection Problem");
}]
以前是 localhost/hiscores 显然不会再工作了。
最佳答案
没有堆栈跟踪很难,但我注意到您的 url 中缺少数据库名称,它应该是这样的:
con = DriverManager.getConnection(
"jdbc:mysql://fdb4.awardspace.com/hiscores", "1191306_hiscores", "passremoved");
注意 jdbc:mysql://fdb4.awardspace.com/hiscores
与 jdbc:mysql://fdb4.awardspace.com/
关于java - MySQL/Java 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13371049/