1:Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/exam", "root", "321");
2:Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/exam?user=root&password=321");
3: Properties prop = new Properties();
prop.put("user", "root");
prop.put("password", "321");
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/exam",prop);
获取数据库连接的三种方式(已经注册驱动)
原创
©著作权归作者所有:来自51CTO博客作者wx5c08995b28fc1的原创作品,请联系作者获取转载授权,否则将追究法律责任

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
spring 连接数据库的三种配置方式
web项目配置数据库连接的方式汇总 CreateTime--2016年12月25日11:13:00 Author:Marydon 方式一:
XML配置 oracle spring Source -
注册Jdbc驱动程序的三种方式
注册Jdbc驱动程序的三种方式
数据库 System bc mysql -
php连接数据库的三种方式的总结
在我们访问 MySQL 数据库前,我们需要先连接到数据库服务器:以面向对象的方式mysqli
php mysql 数据库服务器 数据库 其他 -
spring配置datasource三种方式 数据库连接池
spring配置datasource三种方式 数据库连接池
java springboot spring springmvc -
PHP连接MySQL数据库的三种方式(mysql、mysqli、pdo)--续
2.PHP与Mysqli扩展,面向过程、对象 2.PHP与PDO扩展,面向过程、对象
php mysql sql 数组 面向过程 -
redis如何创建namespace redis如何创建两个无序集合
本文使用的redis客户端为go-redis准备步骤客户端的连接: 导入go-redis包:github.com/go-redis/redis/v8 创建客户端:client := redis.NewClient(&redis.Options{ Addr: "192.168.7.4:6379", Password: "", DB: 0, })使用注解:集合
redis如何创建namespace redis go-redis redis集合 golang redis