Localhost
connection = DriverManager
.getConnection("jdbc:mysql://localhost:3306/skead","admin", "admin");
这是访问我的localhost数据库的一种方法。
但是如果我想访问我的服务器数据库(不是localhost)呢? 我怎么能这样做?
答案 0 :(得分:2)
然后您需要提供网址作为
jdbc:mysql://yourRemoteHost:portToWhichRemoteHostMysqlListens/remoteDBName
答案 1 :(得分:1)
connection = DriverManager.getConnection("jdbc:mysql://Server_Name/DBName","UserName", "Password");
答案 2 :(得分:0)
String dbURL = "jdbc:mysql://serverIPAddress:3307/db_name";
String username = "root";
String password = "redmouse";
// String dbURLs = "jdbc:mysql://localhost/db_name";
// String usernames = "root";
// String passwords = "redmouse";
Connection dbCon = DriverManager.getConnection(dbURL, username, password);