java - 如何将 Java 桌面应用程序连接到在线 mysql 数据库?

标签 java mysql

如标题所示,我想让我的桌面 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/

相关文章:

java - java中的字符串到字符数组

mysql - 如何获取特定列未链接到另一个表的特定值的数据库表条目?

php - 无法使用 Mysql 在 Laravel 中创建外键

php - 与 zend Framework 2 相关的数据库表

java - PixelGrabber 与 getRGB 哪个更快?

java - JNDI 属性(java.naming.factory.initial 和 java.naming.provider.url)未通过 Spring 的 PropertyPlaceholderConfigurer 设置

java - 使用JodaTime获取一分钟的标准秒数

mysql - 删除所有不在 UPDATE 中的行

mysql - MySQL 的 Nhibernate 映射工具

java - Java Comparator.comparing() 类型签名是什么意思?