Database connection pool: (inside put a lot of connection data links, responsible for allocation, management, release database connection, reusable connection, but not new) for data Unified connection to establish a buffer pool, put a certain database connection, use in the buffer pool inside take, and then back to the buffer pool, and then use, do not need to create new;
---------------------------------------------------------------------------------------
Basic methods:
/*
* DBCP data Source: Need to use rack package Dbcp.jar
Add the jar package, rely on the Commons pool this rack package
Create a database connection pool
The common properties are set.
Get a connection to a database from a data source
* */
public void testdbcp () throws sqlexception{
Basicdatasource Datasource=null;
1. Creating an DBCP Data source instance
Datasource=new Basicdatasource ();
2. Specify the required properties for the data source instance
Driver=com.mysql.jdbc.driver
Jdbcurl=jdbc:mysql://localhost:3306/lxn
Datasource.setusername ("root");
Datasource.setpassword ("lxn123");
Datasource.seturl ("Jdbc:mysql://localhost:3306/lxn");
Datasource.setdriverclassname ("Com.mysql.jdbc.Driver");
System.out.println (Datasource.getusername ());
3. Get the connection from the data source
Connection connection=datasource.getconnection ();
System.out.println (connection);
}
Database connection pool (set up a buffer pool for data unification, now used by Enterprise development)