当前位置:网站首页>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>
边栏推荐
- Teach you to easily learn the type of data stored in the database (a must see for getting started with the database)
- Cognitive fallacy: Wittgenstein's ruler
- Asynchronous artifact: implementation principle and usage scenario of completable future
- Some 5000+ likes, the development notes of a director of cosmic factory, leaked
- 2022 high altitude installation, maintenance and removal of examination question bank and high altitude installation, maintenance and removal of examination papers
- Farmersworld farmers world, no faith, how to talk about success?
- How can enterprises and developers take advantage of the explosion of cloud native landing?
- Blue Bridge Cup Guoxin Changtian MCU -- program download (III)
- Analysis report on the development trend and Prospect of global and Chinese supercontinuum laser source industry Ⓚ 2022 ~ 2027
- [dynamic programming] Jisuan Ke: Jumping stake (variant of the longest increasing subsequence)
猜你喜欢

Collection | pytoch common loss function disassembly

Firefox set up proxy server

2022 safety officer-b certificate examination summary and safety officer-b certificate simulation test questions

Niuke winter vacation training camp 4 g (enumeration optimization, Euler power reduction)

The latest analysis of R1 quick opening pressure vessel operation in 2022 and the examination question bank of R1 quick opening pressure vessel operation

4 environment construction -standalone ha

540. Single element in ordered array

1068. Consolidation of ring stones (ring, interval DP)

How can enterprises and developers take advantage of the explosion of cloud native landing?

Redis single thread and multi thread
随机推荐
Exness: the Central Bank of England will raise interest rates again in March, and inflation is coming
Report on the development strategy of China's engineering bidding agency and suggestions for the 14th five year plan Ⓙ 2022 ~ 2028
Rest参考
UC Berkeley proposes a multitask framework slip
Report on the development status and investment planning trends of China's data center industry Ⓡ 2022 ~ 2028
js demo 计算本年度还剩下多少天
DR-NAS26-Qualcomm-Atheros-AR9582-2T-2R-MIMO-802.11-N-5GHz-high-power-Mini-PCIe-Wi-Fi-Module
540. Single element in ordered array
Label coco format data and format data in the upper left corner and lower right corner are mutually converted
China HDI market production and marketing demand and investment forecast analysis report Ⓢ 2022 ~ 2028
Teach you to easily learn the type of data stored in the database (a must see for getting started with the database)
Yyds dry goods inventory hands-on teach you to create a jigsaw puzzle using the canvasapi
How to obtain opensea data through opensea JS
Leetcode problem solving - 235 Nearest common ancestor of binary search tree
What are the common computer problems and solutions
Redis single thread and multi thread
Development trend and market demand analysis report of China's energy storage battery industry Ⓩ 2022 ~ 2028
Investment planning analysis and prospect prediction report of China's satellite application industry during the 14th five year plan Ⓑ 2022 ~ 2028
Dynamic research and future planning analysis report of China's urban water supply industry Ⓝ 2022 ~ 2028
JS Demo calcule combien de jours il reste de l'année