当前位置:网站首页>database connection pool
database connection pool
2022-08-07 20:22:00 【Zhang Mingming】
数据库连接池
Druid为监控而生的数据库连接池,它是阿里巴巴开源平台上的一个项目.Druid是Java语言中最好的数据库连接池,Druid能够提供强大的监控和扩展功能.它可以替换DBCP和C3P0连接池.Druid提供了一个高效、功能强大、可扩展性好的数据库连接池.
作者:索伦x
链接:https://www.jianshu.com/p/6e01354213d8
来源:简书
著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处.
Database connections are large resource items,It can be uniformly provisioned by the database connection pool.
写一下Driud的入门
The first step is to importDruid的jar包.
import java.sql.Connection;
import java.util.Properties;
/** * Druid数据库连接池 */
public class DruidDemo1 {
public static void main(String[] args) throws Exception {
//1配置jar包
//2加载配置文件
Properties properties=new Properties();
properties.load(new FileInputStream("jdbc-01\\src\\druid.properties"));//配置文件的相对路径
//获取连接
DataSource dataSource = DruidDataSourceFactory.createDataSource(properties);
Connection connection = dataSource.getConnection();
/** * 获取了connectionthen you can writesql操作数据库了 * 可以选择statement或者preparestatement来执行sql */
System.out.println(connection);
//The following can output the root path of the current project,From this you can know the relative path of the file
System.out.println(System.getProperty("user.dir"));
}
}
properties.load(new FileInputStream(“jdbc-01\src\druid.properties”));//配置文件的相对路径
This is my config file path.
看一下配置文件
driverClassName=com.mysql.jdbc.Driver//This is used to load the driver.
url,username,passwordis the same as before.
边栏推荐
- 线性预测和自回归建模
- What is an XSS attack?
- What is a split brain
- Tcache Stashing Unlink Attack 原理详解
- Leetcode 剑指 Offer 17. 打印从1到最大的n位数(可以,一次过)
- "Daily practice, happy water problem" 1408. String matching in arrays
- 利物浦大学:Tudor Jianu | CathSim:一个用于自主插管的开源模拟器
- [The Beauty of Software Engineering - Column Notes] "One Question and One Answer" Issue 4 | 14 Common Problem Solving Strategies for Software Development
- 数据(包括图片)写入Excel的实现总结
- JMeter笔记7 | JMeter脚本回放
猜你喜欢
随机推荐
一般处理程序ashx接入微信服务器配置
体验第一个spark程序(第四弹)
Mysql.索引数据结构演进
AAAI2020】阿里DMR:融合Matching思想的深度排序模型
MONAI_Label 安装试用
Unity 最新UnityWebRequest下载,同时显示下载进度,和 显示网速,今天贴出来和大家分享
Shell编程之正则表达式
ECCV2022|面向大规模场景的小目标检测:综述和 benchmark
Centos 7.7 mysql8.0.29 binary installation
Database table design with tree structure
【C#语言】DataGridView排序筛选
OpenCV 画点 画线 画框 写字操作
makefile小技巧
高并发+海量数据下如何实现系统解耦?【上】
语法基础(判断语句)
注册中心设计(1)-注册中心的作用及设计分析
函数简介篇——container_of 宏的理解
conda环境启动jupyter notebook,但是环境没有切换的问题
云原生核心技术(一文搞懂云原生)
渥太华大学:Hao Zhou | 用于6G中基于深度强化学习的波束管理的联合传感和通信







