当前位置:网站首页>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 在性能测试中的应用
数据库性能测试
- 背景
- 步骤



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


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


边栏推荐
- 杰理之进入 soft off 后插拔 sd 卡会复位【篇】
- 不止雷军 iQOO产品经理也称赞高通骁龙8+:焕然一新
- Yaxiang spice listed on Shenzhen Stock Exchange: with a market value of 4billion, Dinglong Bohui and Yongyao investment are shareholders
- Basic knowledge of assembly language (1)
- User analysis aarrr model (pirate model)
- Is PMP useful?
- Timertasks notes
- STM32 (IX) -- can
- Advanced network accounting notes (6)
- STM32 (VIII) -- PWM output
猜你喜欢

【NOI2014】15.起床困難綜合症【二進制】

汇编语言(1)基础知识

20set introduction and API

Online text entity extraction capability helps applications analyze massive text data

Heavyweight: the domestic ide was released, developed by Alibaba, and is completely open source! (high performance + high customization)

今年,安徽母基金大爆发
![Jerry's broadcast MP3 prompt sound function [chapter]](/img/25/58c0f15a6fb2449ac505a06bb15887.png)
Jerry's broadcast MP3 prompt sound function [chapter]

19 classic cases of generator functions

halcon知识:区域(Region)上的轮廓算子(1)

Noah fortune passed the hearing: with an annual revenue of 4.3 billion yuan, Wang Jingbo has 49% voting rights, and Sequoia is a shareholder
随机推荐
sed replace \tPrintf to \t//Printf
韬略生物冲刺科创板:年亏损过亿 实控人张大为夫妇为美国籍
CV convolution neural network
Virtp4 notes
Principles of microcomputer Chapter 5 notes arrangement
【NOI2014】15.起床困难综合症【二进制】
When Jerry's serial port is set up, it prints garbled code, and the internal crystal oscillator is not calibrated [chapter]
诺亚财富通过聆讯:年营收43亿 汪静波有49%投票权,红杉是股东
Jerry's dynamic switching vcomo modulation method [chapter]
【NOI2014】15. Difficult to get up syndrome [binary]
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
傑理之串口設置好以後打印亂碼,內部晶振沒有校准【篇】
Various solutions to knapsack problems
【One by One系列】IdentityServer4(八)使用EntityFramework Core对数据进行持久化
Basic knowledge of penetration test
Noah fortune passed the hearing: with an annual revenue of 4.3 billion yuan, Wang Jingbo has 49% voting rights, and Sequoia is a shareholder
Principles of microcomputer Chapter 6 notes arrangement
CV background introduction
三一重能科创板上市:年营收102亿 市值470亿
Advanced network accounting notes (6)