当前位置:网站首页>C3p0 connection MySQL 8.0.11 configuration problem
C3p0 connection MySQL 8.0.11 configuration problem
2022-07-03 22:25:00 【zhang__ one thousand two hundred and thirty-four】
C3P0 Connect MySQL There are two ways
The first one is : Related parameters Specify in the program user url password
@Test
public void testc3p0_01() throws Exception {
//1. Create a data source object
ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource();
//2. Through the configuration file mysql.properties
Properties properties = new Properties();
properties.load(new FileInputStream("src\\mysql.properties"));
String user = properties.getProperty("user");
String password = properties.getProperty("password");
String url = properties.getProperty("url");
String driver = properties.getProperty("driver");
// To data source comboPooledDataSource Set the relevant parameters
// The management of connections is done by comboPooledDataSource Managed
comboPooledDataSource.setDriverClass(driver);
comboPooledDataSource.setJdbcUrl(url);
comboPooledDataSource.setUser(user);
comboPooledDataSource.setPassword(password);
// Initialization of connections
comboPooledDataSource.setInitialPoolSize(10);
// maximum connection
comboPooledDataSource.setMaxPoolSize(50);
Connection connection = comboPooledDataSource.getConnection();// This method is from DataSource Interface implemented
System.out.println(" Successful connection ");
}
The second way
public void testc3p0_02() throws SQLException {
ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource("hsp_edu");
Connection connection = comboPooledDataSource.getConnection();
System.out.println(" Successful connection ");
connection.close();
}
The configuration file c3p0-config.xml It should be different from the old version
<!-- drive -->
<property name="driverClass">com.mysql.cj.jdbc.Driver</property>
<!-- url-->
<property name="jdbcUrl">jdbc:mysql://localhost:3306/db02?useSSL=false&serverTimezone=UTC&characterEncoding=utf-8&autoReconnect=true</property>
边栏推荐
- Yyds dry goods inventory hands-on teach you to create a jigsaw puzzle using the canvasapi
- Common problems in multi-threaded learning (I) ArrayList under high concurrency and weird hasmap under concurrency
- On my first day at work, this API timeout optimization put me down!
- regular expression
- This time, thoroughly understand bidirectional data binding 01
- What indicators should be paid attention to in current limit monitoring?
- Teach you to easily learn the type of data stored in the database (a must see for getting started with the database)
- How to restore the factory settings of HP computer
- [golang] leetcode intermediate - alphabetic combination of island number and phone number
- Rest参考
猜你喜欢

This time, thoroughly understand bidirectional data binding 01

Farmersworld farmers world, no faith, how to talk about success?

Control loop of program (while loop)

Introduction to kubernetes

2022 safety officer-b certificate examination summary and safety officer-b certificate simulation test questions
![[dynamic programming] Ji Suan Ke: Suan tou Jun breaks through the barrier (variant of the longest increasing subsequence)](/img/6c/2d48d441fee1981a271319fd9f6c23.jpg)
[dynamic programming] Ji Suan Ke: Suan tou Jun breaks through the barrier (variant of the longest increasing subsequence)

Harbor integrated LDAP authentication

Blue Bridge Cup Guoxin Changtian single chip microcomputer -- software environment (II)

1 Introduction to spark Foundation
![[Android reverse] use the DB browser to view and modify the SQLite database (copy the database file from the Android application data directory | use the DB browser tool to view the data block file)](/img/6e/3ffa91154a718b6ace6c8ca87c5995.jpg)
[Android reverse] use the DB browser to view and modify the SQLite database (copy the database file from the Android application data directory | use the DB browser tool to view the data block file)
随机推荐
Pat grade A - 1164 good in C (20 points)
Awk getting started to proficient series - awk quick start
How to obtain opensea data through opensea JS
[sg function] 2021 Niuke winter vacation training camp 6 h. winter messenger 2
BUUCTF,Misc:LSB
国泰君安证券开户是安全可靠的么?怎么开国泰君安证券账户
2022 electrician (elementary) examination questions and electrician (elementary) registration examination
Label coco format data and format data in the upper left corner and lower right corner are mutually converted
Cognitive fallacy: Wittgenstein's ruler
The difference between SRAM and DRAM
Buuctf, misc: sniffed traffic
Summary of basic knowledge of exception handling
Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?
2022 free examination questions for safety management personnel of hazardous chemical business units and reexamination examination for safety management personnel of hazardous chemical business units
Analysis report on the development prospect and investment strategy of global and Chinese modular automation systems Ⓟ 2022 ~ 2027
Go language slice interview real question 7 consecutive questions
Why should enterprises do more application activities?
Report on the development strategy of China's engineering bidding agency and suggestions for the 14th five year plan Ⓙ 2022 ~ 2028
WFC900M-Network_ Card/Qualcomm-Atheros-AR9582-2T-2R-MIMO-802.11-N-900M-high-power-Mini-PCIe-Wi-Fi-Mod
[sg function]split game (2020 Jiangxi university student programming competition)