import com.mchange.v2.c3p0.*;
import java.sql.*;
public class DBconnectionpool{
public static void main(String ar[]) throws Exception{
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setDriverClass( "oracle.jdbc.driver.OracleDriver" );
cpds.setJdbcUrl( "jdbc:oracle:thin:@localhost:1521:xe" );
cpds.setUser("bms");
cpds.setPassword("abc");
cpds.setInitialPoolSize(5);
Connection con = cpds.getConnection();
System.out.println("got the connection"+con);
}
}
执行上述代码后,在 Oracle 监视器页面中,我看不到 5 个物理连接(即,我设置了 cpds.setInitialPoolSize(5)),而我只看到一个连接。