当前位置:网站首页>JDBC 在性能测试中的应用
JDBC 在性能测试中的应用
2022-06-23 18:35:00 【InfoQ】
前言
什么是 JDBC
JDBC 的设计原理
整体架构


static {
try {
java.sql.DriverManager.registerDriver(new Driver());
} catch (SQLException E) {
throw new RuntimeException("Can't register driver!");
}
}
public interface Driver {
//建立连接
Connection connect(String url, java.util.Properties info)
throws SQLException;
boolean acceptsURL(String url) throws SQLException;
DriverPropertyInfo[] getPropertyInfo(String url, java.util.Properties info)
throws SQLException;
int getMajorVersion();
int getMinorVersion();
boolean jdbcCompliant();
public Logger getParentLogger() throws SQLFeatureNotSupportedException;
}
for(DriverInfo aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then
// skip it.
if(isDriverAllowed(aDriver.driver, callerCL)) {
try {
println(" trying " + aDriver.driver.getClass().getName());
Connection con = aDriver.driver.connect(url, info);
if (con != null) {
// Success!
println("getConnection returning " + aDriver.driver.getClass().getName());
return (con);
}
} catch (SQLException ex) {
if (reason == null) {
reason = ex;
}
}
} else {
println(" skipping: " + aDriver.getClass().getName());
}
}
Connection 设计

- DataSource
public interface DataSource extends CommonDataSource, Wrapper {
Connection getConnection() throws SQLException;
Connection getConnection(String username, String password)
throws SQLException;
}
protected Connection getConnectionFromDriver(Properties props) throws SQLException {
Driver driver = getDriver();
String url = getUrl();
Assert.notNull(driver, "Driver must not be null");
if (logger.isDebugEnabled()) {
logger.debug("Creating new JDBC Driver Connection to [" + url + "]");
}
return driver.connect(url, props);
}
- ConnectionPoolDataSource:连接池的实现,此数据源实现并不直接创建数据库物理连接,而是一个逻辑实现,它的作用在于池化数据库物理连接。
- PooledConnection:配合 ConnectionPoolDataSource,由它获取一个池化对象 PooledConnection,再通过该 PooledConnection 间接获取到物理连接。
Statement 设计
- Statement:定义一个静态的 SQL 语句,数据库每次执行都需要重新编译,一般用于仅执行一次查询并返回结果的情形。
- PreparedStatement:定义一个带参的预编译的 SQL 语句,下次执行时,会从缓存中取出遍以后的语句,而不需要重新编译一遍,适用于执行多次相同逻辑的 SQL 语句,当然它还有防 SQL 注入等功能,安全性和效率较高,使用比较频繁。对于性能测试来说,选择 PreparedStatement 最为合适。
- CallableStatement:用来调用存储过程。
ResultSet 设计
JDBC 架构总结
JDBC 在性能测试中的应用
数据库性能测试
- 背景
- 步骤



压测数据构造
- 背景
- 步骤


压测脏数据清理
- 背景
- 步骤


边栏推荐
- Matrix analysis notes (III-1)
- golang set type implementation
- Programmable data plane (paper reading)
- Jerry's serial port communication serial port receiving IO needs to set digital function [chapter]
- Borui data attends Alibaba cloud observable technology summit, and digital experience management drives sustainable development
- NAACL 2022 Findings | 字节提出MTG:多语言文本生成数据集
- Uniswap创始人:不会为Genie发行独立代币,Genie产品将集成至Uniswap界面
- When Jerry's serial port is set up, it prints garbled code, and the internal crystal oscillator is not calibrated [chapter]
- Robust extraction of specific signals with time structure (Part 1)
- Take out Jianghu will change, and meituan "big brother" is hard to be
猜你喜欢

Taolue biology rushes to the scientific innovation board: the actual controllers with annual losses of more than 100 million are Zhang Dawei and his wife, who are American nationals

Halcon knowledge: contour operator on region (1)

不止雷军 iQOO产品经理也称赞高通骁龙8+:焕然一新

FlagAI飞智:AI基础模型开源项目,支持一键调用OPT等模型

直播回顾 | 云原生混部系统 Koordinator 架构详解(附完整PPT)

A review of comparative learning
![When Jerry's serial port is set up, it prints garbled code, and the internal crystal oscillator is not calibrated [chapter]](/img/6d/96b3326a201bf17d436c1af7834232.png)
When Jerry's serial port is set up, it prints garbled code, and the internal crystal oscillator is not calibrated [chapter]

8. AI doctor case
![Develop small programs and official account from zero [phase I]](/img/02/77386ba3fe50b16018f77115b99db6.png)
Develop small programs and official account from zero [phase I]

halcon知识:区域(Region)上的轮廓算子(1)
随机推荐
Une fois que le port série de Jerry est réglé, le Code aléatoire est imprimé, et le cristal interne n'est pas étalonné [chapitre]
Vprom notes
Check four WiFi encryption standards: WEP, WPA, WPA2 and WPA3
Advanced network accounting notes (V)
盘点四种WiFi加密标准:WEP、WPA、WPA2、WPA3
Convex optimization notes
golang set type implementation
User analysis aarrr model (pirate model)
杰理之播 MP3 提示音功能【篇】
Matrix analysis notes (III-1)
重磅:国产IDE发布,由阿里研发,完全开源!(高性能+高定制性)
【对比学习】koa.js、Gin与asp.net core——中间件
[one by one series] identityserver4 (II) using client credentials to protect API resources
打新债 要求 打新债安全吗
物联网平台搭建设备,附源代码
Heavyweight: the domestic ide was released, developed by Alibaba, and is completely open source! (high performance + high customization)
Matrix analysis notes (I)
Advanced network accounting notes (IV)
Netseer: stream event telemetry notes for programmable data plane
杰理之进入 soft off 后插拔 sd 卡会复位【篇】