当前位置:网站首页>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>
边栏推荐
- Investment planning analysis and prospect prediction report of China's satellite application industry during the 14th five year plan Ⓑ 2022 ~ 2028
- 3 environment construction -standalone
- Sow of PMP
- [automation operation and maintenance novice village] flask-2 certification
- Report on the development strategy of China's engineering bidding agency and suggestions for the 14th five year plan Ⓙ 2022 ~ 2028
- How to store null value on the disk of yyds dry inventory?
- How can enterprises and developers take advantage of the explosion of cloud native landing?
- How the computer flushes the local DNS cache
- Uboot migration
- Leetcode problem solving - 230 The k-th smallest element in the binary search tree
猜你喜欢
Yyds dry goods inventory Spring Festival "make" your own fireworks
The reason why the computer runs slowly and how to solve it
Collection | pytoch common loss function disassembly
UC Berkeley proposes a multitask framework slip
[dynamic programming] Ji Suan Ke: Suan tou Jun breaks through the barrier (variant of the longest increasing subsequence)
Functions and differences between static and Const
1 Introduction to spark Foundation
Awk getting started to proficient series - awk quick start
Control loop of program (while loop)
Programming language (1)
随机推荐
Awk getting started to proficient series - awk quick start
Pooling idea: string constant pool, thread pool, database connection pool
JS closure knowledge points essence
Plug - in Oil Monkey
Why should enterprises do more application activities?
2 spark environment setup local
Programming language (1)
[automation operation and maintenance novice village] flask-2 certification
Programming language (2)
Unique in China! Alibaba cloud container service enters the Forrester leader quadrant
Ten minutes will take you in-depth understanding of multithreading. Multithreading on lock optimization (I)
How to switch between dual graphics cards of notebook computer
(POJ - 2912) rochambau (weighted concurrent search + enumeration)
Buuctf, web:[geek challenge 2019] buyflag
How to solve the problem of requiring a password when accessing your network neighborhood on your computer
[secretly kill little partner pytorch20 days] - [day3] - [example of text data modeling process]
Label coco format data and format data in the upper left corner and lower right corner are mutually converted
Pan Yueming helps Germany's Rochester Zodiac custom wristwatch
Common problems in multi-threaded learning (I) ArrayList under high concurrency and weird hasmap under concurrency
2022 electrician (elementary) examination questions and electrician (elementary) registration examination