• 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

Connection Pooling Managment

 
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am configuring datasource for my tomcat v.5.5.25. i did following entry in my context.xml



<Resource name="jdbc/mydatasource" auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@url:servicename"
username="user" password="password"/>


---------------------------------------------------------------------------
public static Connection getConnection() {
Connection conn = null;
if (datasource == null) {
datasource = locateDataSource();

}
if (datasource != null) {
try {
conn = datasource.getConnection();
} catch (SQLException e) {
LOGGER.error("Cannot get connection:" + e.getMessage()+e);
}
}

return conn;
}
/**
* Method to locate data source.
* @return
*/
private static DataSource locateDataSource() {
Context initialContext = null;
String DATASOURCE_CONTEXT = "java:comp/env/jdbc/mydatasource";
try {
initialContext = new InitialContext();
datasource = (DataSource)initialContext.lookup(DATASOURCE_CONTEXT);

} catch (NamingException e) {
LOGGER.error("Cannot get connection:" + e.getMessage() +e);
}
return datasource;

}
-----------------------------------------------------------------------
i take connection like this for my data access layer
connection = DBUtil.getConnection();


there is no problem in picking connections. But as per my reading it is not doing connection pooling at all. Application gets too slow and hangs too often that i have to restart it.
and also how can i make it to use c3p0 for connection pooling.
i have following jar in my tomcat/common/lib - commons-dbcp-1.2.1.jar,ojdbc14.jar

Please suggest.

Thanks in advance
 
Patricia Samuel
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Would any one like to reply on this post???

Please help
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do you know that it's not pooling connections?
 
Patricia Samuel
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to do following changes in the current scenario

1. To make it to use C3P0
2. it is taking so much time in executing a query. Can connection pooling like this help me in accelerating the speed at which queries fire.

I will be really thankful if anyone can help me in solving my problem.

Thanks in advance
 
Patricia Samuel
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is there nobody who can help me in resolving this problem?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Patricia Samuel:
is there nobody who can help me in resolving this problem?



I think you'll more and better responses if you can make your questions a little more clear.

1.) What is C3PO (other than the little robot in Star Wars)?

2.) Establishing a connection to a database is often a very expensive process and can often be the biggest bottleneck in an application. Keeping a pool of already established connections will almost always be faster than creating them on demand.


Beyond those things, do you have another question?
[ May 30, 2008: Message edited by: Ben Souther ]
 
Patricia Samuel
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ben Souther:

Keeping a pool of already established connections will almost always be faster than creating them on demand.
[ May 30, 2008: Message edited by: Ben Souther ]



Hi Ben,

Many thanks for your reply. Would you please explain me how can we make faster our application by having a pool of already established connection. I am more concern about the performance of my application.I would appreciate if some one can help me know the way to make application faster.

Thanks a lot
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using connection pooling now?
 
Patricia Samuel
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, i am still using the code that i mentioned in my first post regarding this.i have set maxsize and minsize. But my application does not execute query fast.My tomcat is using dpcp for connection pooling.
 
Those who dance are thought mad by those who hear not the music. This tiny ad plays the bagpipes:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic