当前位置:网站首页>JDBC 在性能測試中的應用
JDBC 在性能測試中的應用
2022-06-23 19:24: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 在性能測試中的應用
數據庫性能測試
- 背景
- 步驟



壓測數據構造
- 背景
- 步驟


壓測髒數據清理
- 背景
- 步驟


边栏推荐
- Leetcode daily question - 30 Concatenate substrings of all words
- [one by one series] identityserver4 (IV) authorization code process
- 【对比学习】koa.js、Gin与asp.net core——中间件
- JDBC 在性能测试中的应用
- Robust extraction of specific signals with time structure (Part 1)
- 杰理之进入 soft off 后插拔 sd 卡会复位【篇】
- Matrix analysis notes (II)
- Robust extraction of specific signals with time structure (Part 2)
- Helix QAC更新至2022.1版本,将持续提供高标准合规覆盖率
- Timertasks notes
猜你喜欢

Robust extraction of specific signals with time structure (Part 2)

Shunted self attention | vit method for solving small target problems, which is derived from PVT and higher than PVT

20set introduction and API

What does logistics service and management mainly learn

Sany Heavy energy technology innovation board listed: annual revenue of RMB 10.2 billion and market value of RMB 47 billion

Basic knowledge of assembly language (1)

Netcf summary

#20Set介绍与API

Docker builds redis cluster

Idea console displays Chinese garbled code
随机推荐
Advanced network accounting notes (6)
打新债需要具备什么条件 打新债安全吗
博睿数据出席阿里云可观测技术峰会,数字体验管理驱动可持续发展
What does logistics service and management mainly learn
考PMP有用吗?
Programmable, protocol independent software switch (read the paper)
Is PMP useful?
Product design - Requirements Analysis
如何通过7个步骤编写出色的在线用户手册
Matrix analysis notes (III-1)
[one by one series] identityserver4 (VIII) uses entityframework core to persist data
User analysis aarrr model (pirate model)
好用的人事管理软件有哪些?人事管理系统软件排名!
[one by one series] identityserver4 (II) using client credentials to protect API resources
[one by one series] identityserver4 (IV) authorization code process
Obtain equipment information
golang set type implementation
Uniswap创始人:不会为Genie发行独立代币,Genie产品将集成至Uniswap界面
Function definition and function parameters
直播回顾 | 云原生混部系统 Koordinator 架构详解(附完整PPT)