4

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

2
  • 2
    As you said connection pool. :) Try using datasource of server that will save you from implementing connection pool. Commented Mar 8, 2013 at 10:38
  • You can use Apache Commons DBCP for connection pooling. There are others too. Commented Mar 8, 2013 at 10:53

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

0

Ill suggest you use JNDI code for implementing the connection code. the Application server can take care of the connection pooling. for example in weblogic server u can set the connection pool size.

dont go re-inventing the wheel and use the AS features. will help..

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.