This connection pool is obtained directly from JIVE and is modified so that the connection parameters are directly set in the program rather than read from the property file.
Usage:
Set your own connection parameters in the loadProperties method of the DbConnectionDefaultPool. java file. Note that you also need to set the storage location of log files in the connection pool.
String driver = "org. gjt. mm. mysql. Driver"; // This is the JDBC driver used.
String server = "jdbc: mysql: // 192.100.100.1/qingtuo"; // URL used
// String server = "jdbc: mysql: // 192.168.0.1/qingtuo ";
String username = "qingtuo ";
String password = "qingtuo ";
String minConnections = "3"; // minimum number of connections
String maxConnections = "20"; // maximum number of connections
String logPath = "c: tempqingtuoDbLog. log"; // log File Location
// String logPath = "/tmp/qingtuoDbLog. log ";
String connectionTimeout = "0.5"; // periodically clear useless connection intervals (in days)
Then
In your program, you only need to import the package com. qingtuo. db. pool and use it as follows.
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
Try {
Con = DbConnectionManager. getConnection ();
// Write your SQL statement here
}
Catch (SQLException sqle ){
Throw sqle;
}
Finally {
Try {
Pstmt. close ();
}
Catch (Exception e ){
E. printStackTrace ();
}
Try {