aspose file tools*
The moose likes Struts and the fly likes Coonection pooling problem..... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Coonection pooling problem....." Watch "Coonection pooling problem....." New topic
Author

Coonection pooling problem.....

Kaleeswaran Karuppasamy
Ranch Hand

Joined: Jul 19, 2007
Posts: 154
Dear friend i am working in company we developed a product using struts.we were used Struts-config datasource connection pooling and we are developed 60 sub module each module have its own struts config file.however the problem is each every transaction server side created seperate connection pooling .if we are using 10 our product nearly 150 connection pooling created.finally we changed jndi access using this below coding..


package com.imanager.jndi.businessdelegate.servicelocator;
import java.util.*;
import javax.naming.*;
import java.rmi.RemoteException;
import javax.rmi.PortableRemoteObject;
import java.io.*;
import javax.sql.DataSource;
import java.sql.Connection;
public class ServiceLocator {

private volatile static ServiceLocator me;
InitialContext context = null;
DataSource dataSource=null;
private ServiceLocator()
throws Exception {
try {
context = new InitialContext();
} catch(NamingException ne) {
throw new Exception();
}
}

public static ServiceLocator getInstance()
throws Exception {
if (me == null) {
synchronized(ServiceLocator.class){
if (me == null) {
me = new ServiceLocator();
}
}
}
return me;
}

public Connection getConnection(){
Connection conn=null;
try{

dataSource = (DataSource)context.lookup("java:/comp/env/jdbc/IMDB");
conn=dataSource.getConnection();

} catch( Exception ne ) {
throw new RuntimeException( "Unable to aquire Connection", ne );
}
return conn;
}


public DataSource getDataSource(){
Connection conn=null;
try {
dataSource = (DataSource)context.lookup("java:/comp/env/jdbc/IMDB");

} catch( Exception ne ) {
throw new RuntimeException( "Unable to aquire data source", ne );
}
return dataSource;
}


}

we are using tomcat..

using this class we accessing database connection...

eventhough there is lot of connection pooling created in server side...




please suggest me which is the better way to control the connection pooling creation in server side .....

code

postgres 7911 0.0 0.6 43640 5132 ? S 01:04 0:00 postgres: postgres IManager 192.168.10.88 idle
postgres 7917 0.0 1.0 44696 7812 ? S 01:05 0:00 postgres: postgres IManager 192.168.10.88 idle
postgres 7919 0.0 0.7 43760 5556 ? S 01:05 0:00 postgres: postgres IManager 192.168.10.88 idle
postgres 7920 0.0 0.9 44540 7252 ? S 01:05 0:00 postgres: postgres IManager 192.168.10.88 idle
postgres 8085 0.0 0.7 43632 5608 ? S 01:11 0:00 postgres: postgres IManager 192.168.10.88 idle
postgres 8086 0.0 0.7 43632 5676 ? S 01:11 0:00 postgres: postgres IManager 192.168.10.88 idle
postgres 8087 0.0 0.7 43632 5720 ? S 01:11 0:00 postgres: postgres IManager 192.168.10.88 idle
postgres 8088 0.0 0.7 43632 5720 ? S 01:11 0:00 postgres: postgres IManager 192.168.10.88 idle
postgres 8093 0.0 0.7 43632 5820 ? S 01:11 0:00 postgres: postgres IManager 192.168.10.88 idle
postgres 8114 0.0 0.7 43632 5676 ? S 01:11 0:00 postgres: postgres IManager 192.168.10.88 idle
postgres 8115 0.0 0.7 43632 5720 ? S 01:11 0:00 postgres: postgres IManager 192.168.10.88 idle
postgres 8116 0.0 0.7 43632 5844 ? S 01:11 0:00 postgres: postgres IManager 192.168.10.88 idle
postgres 8117 0.0 0.6 43376 4788 ? S 01:11 0:00 postgres: postgres IManager 192.168.10.88 idle
postgres 8118 0.0 0.6 43628 5132 ? S 01:11 0:00 postgres: postgres IManager 192.168.10.88 idle
postgres 8131 0.0 0.5 43376 3832 ? S 01:12 0:00 postgres: postgres IManager 192.168.10.88 idle
postgres 8290 0.0 0.8 43632 6212 ? S 01:24 0:00 postgres: postgres IManager 192.168.10.88 idle
postgres 8295 0.0 0.7 43632 5676 ? S 01:25 0:00 postgres: postgres IManager 192.168.10.88 idle
postgres 8296 0.0 0.7 43632 5720 ? S 01:25 0:00 postgres: postgres IManager 192.168.10.88 idle
postgres 8297 0.0 0.7 43632 5716 ? S 01:25 0:00 postgres: postgres IManager 192.168.10.88 idle
postgres 8300 0.0 0.8 43632 6424 ? S 01:25 0:00 postgres: postgres IManager 192.168.10.88 idle
postgres 8361 0.0 0.7 43632 5676 ? S 01:31 0:00 postgres: postgres IManager 192.168.10.88 idle
...............
...............
keep on created like this


Judge a man by his questions rather than his answers --Voltaire
SCJP 1.5 97%
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Coonection pooling problem.....