将Java连接到MySQl数据库
是否有一种标准方法可以将 Java 程序连接到 MySQL 数据库,哪种方法是最简单的?
Is there a standard way to connect a Java program to a MySQL database, and which is the easiest one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
JDBC 也是 JDBC 的标准方式。 oracle.com/javase/tutorial/jdbc/overview/index.html" rel="nofollow">最简单。
JDBC is the standard way also the easiest.
除了上面发布的答案之外,一旦您跨越了称为学习曲线的初始障碍(并且在您遇到称为性能优化的下一个障碍之前),JPA(Hibernate)甚至会变得更容易。严肃地说,是的,JPA 也是一种以相同方式连接和查询几乎任何数据库的标准方法。
In addition to answer posted above, JPA (Hibernate) is even easier one once you cross the initial barrier called learning curve (and before you are hit by next one called, Performance Optimization). On the serious note, Yes JPA is also a standard way to connect and query pretty much any database the same way.
JDBC 是标准方式。下面是连接MySQL数据库的java代码示例:
JDBC is the standard way. Below is the sample java code to connect MySQL database:
也许使用 Hibernate 进行对象关系映射对您来说是一种有用的方法。
Maybe object-relational mapping with Hibernate is a useful way for you.