tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From IT Desk <...@dataeffects.com>
Subject jsp optimization for db driver load and connection
Date Mon, 04 Dec 2006 19:03:45 GMT
This isn't Tomcat specific but general to any jsp container and its jvm.

I am working on a site where almost everything is done through the jsp 
page plus one main java class to store state data.

The site's jsp page may do up to 7 queries on the database. On each 
query, the statements are these:

Driver DriverDB = (Driver)Class.forName(db_DRIVER).newInstance();
Connection ConnDB = 
DriverManager.getConnection(db_STRING,db_USERNAME,db_PASSWORD);
PreparedStatement StatementDB = ConnDB.prepareStatement("SELECT * from 
table");
ResultSet resultDB = StatementDB.executeQuery();

My 2 questions are:
Does the forName call to load the driver get optimized out? Clearly the 
driver need only load once.
Does the getConnection reuse the same connection that was done in the 
previous call on the same jsp page?

There are some performance problems and I'm wondering if I should try to 
clean the code up or if the jvm
does it for me through optimization. It's running on Tomcat 5.5.20 and 
JVM 5.x.

The client won't pay for any major redesign so I'm looking for something 
small that could make a big impact.

Thanks for any insight.
Coral

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message