We plan to implement connection pooling into our java application. We google and found a number of it such as BoneCp,DbPool,Apache,c3p0,DbCp and others. The problem now we are finding difficult to make a decision to which one to apply as some are outdated. Which method will be best solution?
public class cServer
{
class ConnectionHandler implements Runnable {
ConnectionHandler(Socket receivedSocketConn1) {
this.receivedSocketConn1=receivedSocketConn1;
}
public void run(){
createConnection();
while (read the socket values){
//number of queries to run in terms of select,insert and updates.
}
closeConnection();
}
void createConnection(){
try{
dbconn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test1?"+"user=user1&password=*******");
dbconn.setAutoCommit(false);
}
catch(Throwable ex){
ex.printStackTrace(System.out);
}
}
}
public void main()
{
try
{
final ServerSocket serverSocketConn = new ServerSocket(8000);
while (true){
try{
Socket socketConn1 = serverSocketConn.accept();
new Thread(new ConnectionHandler(socketConn1)).start();
}
catch(Exception e){
e.printStackTrace(System.out);
}
}
}
catch (Exception e){
e.printStackTrace(System.out);
}
}
}