• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Coonection pooling problem.....

 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
My honeysuckle is blooming this year! Now to fertilize this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic