aspose file tools*
The moose likes Servlets and the fly likes Connection Pooling Problem ...PLEASE HELP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Connection Pooling Problem ...PLEASE HELP" Watch "Connection Pooling Problem ...PLEASE HELP" New topic
Author

Connection Pooling Problem ...PLEASE HELP

DC Dalton
Ranch Hand

Joined: May 28, 2001
Posts: 287
I am having all sorts of problems with connection pooling, primarily because I have a hosting comapny with the head up their, well we neednt say that here. We are running a unix box (apache) that runs resin 2.0.1 with a MySQL db. The really stupid part here is this version of Resin supports pooling with their com.caucho.sql package and a few lines in the config file but these morons DONT SUPPORT CONNECTION POOLING.......Ive tryed to explain to them time after time that its to there benefit to support it but they just dont get it. They refuse to put the above mentioned package in the machines classpath!
Anyway, this site is growing like wildfire and weird problems are happening (exceptions OUTSIDE of the JVM) and I have to think its WAY too many connections to the db...Ive read enough here at Javaranch to know this is a BIG no-no. I have the javaExchange connection broker package working fine on my local machine as well as the caucho package but I cant for the life of me get it to work on the Unix box. Its either not finding the package OR its not finding the error.log file...I keep getting null pointer exceptions on ANY connection attempt.
My question here is how to set up this thing and find both the package (which I have in both the web-inf/classes folder and the web-inf/lib folder AND find the error.log file which is 4 folders down on the server tree (On my partition's root)???
Here is the normal connectionBroker code which works just ducky on my Win2k machine with the error.log file hardcoded to its absolute path:
public void init(ServletConfig config) throws ServletException {
super.init(config);
try {
myBroker = new DbConnectionBroker("org.gjt.mm.mysql.Driver","jdbc:mysql://localhost:3306/[dbName]","[dbUserName]","[dbPassword]",2,6,"F:\\resin\\log\\error.log",0.01);
}
catch (IOException e5)
{ }
}
How the heck can I set this up to find the log file WITHOUT the full, absolute path on the UNIX box (there is NO WAY their going to give me that)...AND how can I tell this thing to find the package com.javaExchange.dbConnectionBroker if its not in the machines classpath!!!
I really would appreciate ANY help I can get here....the site is crashing twice a day (usually high traffic points) & I have to think this is the problem!! Some hosting companies just dont get it!! Thanks all!

[This message has been edited by DC Dalton (edited October 30, 2001).]
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
For a start, ServletContext.getRealPath("/") will give you the filesystem path to your web-app, provided that the application server serves its content from the filesystem in the first place (in your case that should be OK). You can use that to construct a suitable path to a logfile.
You should be able to simply stuff your jars in WEB-INF/lib (or classes in WEB-INF/classes).
Finally, rather than using a proprietary connection pool, why don't you use the Struts org.apache.struts.util.GenericDataSource? This is a nifty pool that will turn any old JDBC driver into a pooled, industry-standard DataSource with all the necessary trappings. Use a 10-line initialisation servlet to instantiate it and bind it somewhere appropriate (application scope, for instance). When you move to a container or driver that supports pooled DataSources natively, use a servlet which binds that instead and configure that in, no code changes necessary.
- Peter
DC Dalton
Ranch Hand

Joined: May 28, 2001
Posts: 287
You definately have me intigued with this Struts package. Where can I find information on it and possibly a code sample or two.....thanks for all your help
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Struts is an MVC framework comprising a controller and a bunch of tag libraries. The tag libraries encompass logic (iteration, conditionals), html generation (auto-populating fields!), JavaBean manipulation (infinitely more powerful than jsp:useBean and jsp:getProperty) and templates. The controller is fairly crude IMHO, but the way it integrates with the tag libraries is impressive and Struts makes forms-driven web applications, with or without i18n, very easy to develop. General quality is high.
The GenericDataSource class I mentioned is one of the utility classes that come with Struts. You can use it independently from the rest of the framework and it is definitely worth checking out.
- Peter
[This message has been edited by Peter den Haan (edited November 01, 2001).]
DC Dalton
Ranch Hand

Joined: May 28, 2001
Posts: 287
Thanks for you help Peter, Ive managed to get the javaexchange pool to run using the servlet context (To be honest I completely forgot about that) I will look at this package and see what kind of goodies they have to offer! Thanks again!
 
wood burning stoves
 
subject: Connection Pooling Problem ...PLEASE HELP
 
Similar Threads
File Logging problem
Resin Connection Pooling Problem
Help !!!!!!! Connection problems from you know where!
File Logging Problem
FileReader - Servlet Problem.....Cant find file