Domanda

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

È stato utile?

Soluzione

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.

Altri suggerimenti

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..

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top