如标题所示,我想让我的桌面 java 应用程序连接到在线 mysql 数据库?!我怎样才能达到这样的连接才能添加和检索数据?!
最佳答案
从 here 下载连接器.将它添加到您的类路径和代码中:
// This will load the MySQL driver, each DB has its own driver
Class.forName("com.mysql.jdbc.Driver");
// Setup the connection with the DB
connect = DriverManager
.getConnection("jdbc:mysql://remoteUri/database-name?"
+ "user=user&password=userpw");
关于java - 如何将 Java 桌面应用程序连接到在线 mysql 数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19362693/