Java基础-数据库配置
参考文献
JDBC连接数据库的流程
-
在开发环境中加载指定数据库的驱动程序
-
在Java程序中加载程序
1
ClassName.forName("com.mysql.cj.jdbc.Driver");
-
创建数据连接对象
1
2// URL = 协议名 + IP地址 + 端口 + 数据库名称
Connection connection = DriverManager.getConnection("连接数据库的URL","用户名","密码"); -
创建
Statement
对象1
Statement statement = connection.createStatement();
-
调用
Statement
对象的相关方法执行对应的SQL1
ResultSet resulte = statement.excuteUpdate("SQL");
-
关闭数据库连接
1
connection.close();
各种数据库URL配置
1 | mysql: |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 HoleLin's Blog!