【发布时间】:2014-06-03 17:53:45
【问题描述】:
我正在尝试连接到多个数据库,这是我的代码,此代码在本地机器上运行良好,但是当我将其上传到网上时,它无法正常工作,我可以得到任何帮助提前谢谢你。
package dbase.sqlcon;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class ConnectionHelper{
private String url;
private String restrnturl;
private String prptyurl;
private String user= "root";
private String pass= "mysql";
private String userRestaurent= "root";
private String passRestaurent= "mysql";
private String userProperty= "root";
private String passProperty= "mysql";
private ConnectionHelper() {
try {
Class.forName("com.mysql.jdbc.Driver");
URLDecoder.decode(getClass().getClassLoader().getResource("flex/testdrive").toString(), "UTF-8");
url = "jdbc:mysql://192.168.10.1:3306/desisquare";
restrnturl="jdbc:mysql://192.168.10.1:3306/foodndine";
prptyurl="jdbc:mysql://192.168.10.1:3306/postaproperty";
} catch (Exception e) {
e.printStackTrace();
}
}
public static Connection getConnection() throws SQLException {
if (instance == null) {
instance = new ConnectionHelper();
}
return DriverManager.getConnection(instance.url, instance.user, instance.pass);
}
public static Connection getConnectionrestaurent() throws SQLException {
if (instance == null) {
instance = new ConnectionHelper();
}
return DriverManager.getConnection(instance.restrnturl, instance.userRestaurent, instance.passRestaurent);
}
public static Connection getConnectionproperty() throws SQLException {
if (instance == null) {
instance = new ConnectionHelper();
}
return DriverManager.getConnection(instance.prptyurl, instance.userProperty, instance.passProperty);
}
}
当我问我的托管服务提供商有什么问题时,他发给我这个对我来说非常新的问题
INFO | jvm 1 | 2014/04/18 06:23:03 | Exception is ;java.sql.SQLException: Access denied for user 'postaproperty'@'localhost' (using password: YES)
INFO | jvm 1 | 2014/04/18 06:23:03 | Exception is ;java.sql.SQLException: Access denied for user 'postaproperty'@'localhost' (using password: YES)
INFO | jvm 1 | 2014/04/18 06:23:03 | Exception is ;java.sql.SQLException: Access denied for user 'foodndine'@'localhost' (using password: YES)
【问题讨论】:
-
你检查你的登录数据了吗?
-
yaaa 我已经检查过了。
-
在 SO 中找到一个链接。检查stackoverflow.com/questions/1457716/…。还有一件事只是为了调试。仅使用 postaproperty 并部署代码。
-
您是否可以使用您在此处提供的代码登录您的在线数据库?
标签: java mysql database database-connection