<?xml version="1.0" encoding="UTF-8"?> <c3p0-config> <default-config> <property name="jdbcUrl">jdbc:mysql://localhost:3306/test</property> <property name="driverClass">com.mysql.cj.jdbc.Driver</property> <property name="user">username</property> <property name="password">password</property> <property name="maxPoolSize">50</property> <property name="minPoolSize">5</property> <property name="initialPoolSize">10</property> <property name="maxIdleTime">1800</property> </default-config> </c3p0-config> import com.mchange.v2.c3p0.ComboPooledDataSource; import java.sql.Connection; import java.sql.SQLException; public class Main { public static void main(String[] args) { ComboPooledDataSource dataSource = new ComboPooledDataSource(); try { Connection connection = dataSource.getConnection(); // ... } catch (SQLException e) { e.printStackTrace(); } } }


上一篇:
下一篇:
切换中文