当前位置:网站首页>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>
边栏推荐
- Cesium terrain clipping draw polygon clipping
- Go Technology Daily (2022-02-13) - Summary of experience in database storage selection
- How does sentinel, a traffic management artifact, make it easy for business parties to access?
- The overseas listing of Shangmei group received feedback, and brands such as Han Shu and Yiye have been notified for many times and received attention
- Pooling idea: string constant pool, thread pool, database connection pool
- Programming language (1)
- Teach you to easily learn the type of data stored in the database (a must see for getting started with the database)
- Sed、Awk
- js demo 计算本年度还剩下多少天
- Rest reference
猜你喜欢

Pat grade A - 1164 good in C (20 points)

How to solve the problem of computer networking but showing no Internet connection

Introduction to kubernetes

The overseas listing of Shangmei group received feedback, and brands such as Han Shu and Yiye have been notified for many times and received attention

Kali2021.4a build PWN environment
![Buuctf, web:[geek challenge 2019] buyflag](/img/02/d3add04f8145621bff35d46b82ba53.jpg)
Buuctf, web:[geek challenge 2019] buyflag

Control loop of program (while loop)

Preliminary analysis of smart microwave radar module

6.0 kernel driver character driver
![[dynamic planning] counting garlic customers: the log of garlic King (the longest increasing public subsequence)](/img/29/543dce2f24130d22c1824385fbfa8f.jpg)
[dynamic planning] counting garlic customers: the log of garlic King (the longest increasing public subsequence)
随机推荐
3 environment construction -standalone
Supply and demand situation and market scale calculation report of China's portable energy storage power PES industry Ⓛ 2022 ~ 2028
English topic assignment (28)
Market layout planning and latest dynamic analysis report of China's smart public security industry Ⓕ 2022 ~ 2028
Analysis report on the development trend and Prospect of global and Chinese supercontinuum laser source industry Ⓚ 2022 ~ 2027
Ten minutes will take you in-depth understanding of multithreading. Multithreading on lock optimization (I)
Blue Bridge Cup Guoxin Changtian MCU -- program download (III)
Dynamic research and future planning analysis report of China's urban water supply industry Ⓝ 2022 ~ 2028
China's Call Center Industry 14th five year plan direction and operation analysis report Ⓔ 2022 ~ 2028
油猴插件
How to switch between dual graphics cards of notebook computer
How can enterprises and developers take advantage of the explosion of cloud native landing?
Plug - in Oil Monkey
SDNU_ ACM_ ICPC_ 2022_ Winter_ Practice_ 4th [individual]
[sg function] lightoj Partitioning Game
Leetcode problem solving - 235 Nearest common ancestor of binary search tree
Functions and differences between static and Const
How PHP gets all method names of objects
Common problems in multi-threaded learning (I) ArrayList under high concurrency and weird hasmap under concurrency
BUUCTF,Misc:LSB