Copy the code code as follows:
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
import com.mchange.v2.c3p0.ComboPooledDataSource;
/**
* Tool class provides database connection pool and database connection
*
* @author seawind
*
*/
public class JDBCUtils {
private static DataSource dataSource = new ComboPooledDataSource();
public static DataSource getDataSource() {
return dataSource;
}
/**
* When DBUtils needs to manually control the transaction, call this method to obtain a connection
*
* @return
* @throws SQLException
*/
public static Connection getConnection() throws SQLException {
return dataSource.getConnection();
}
}