connection pooling in jdbc using sql server

adesh singh picture adesh singh · Mar 8, 2013 · Viewed 8.4k times · Source

I am trying to make connection through SQL Server from web server using java .It is simply opening the connection by sql driver but when multiple users try to connect with the web server of the company the server goes slow down due to the heavy traffic . So i think it must use the connection pooling concept . i am using the following code to connect with database

   try{   
     Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
       cnn     =java.sql.DriverManager.getConnection("jdbc:sqlserver://202.54.119.141:1433;Database=LCXERP" ,"shivam","shivbabaji");
     st1=cnn.createStatement();


    }
    catch(Excpetion ex)
  {
    ex.printStackTrace();
  }

suggest the alternate way to connect with data base to avoid congestion

Answer

Lakshmi picture Lakshmi · Mar 8, 2013

Connection Pooling can help you. There are various connection pooling avaible most common among them are DBCP connection pooling and C3pO connection pooling. You can refer Sample connection pooling for your guidance . Also you can read more on the advantages of connection pooling here.In general connection pooling can reduce the number of connections made to the backend at a time thereby increasing the performance.