This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Servlets and the fly likes Resource usage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Servlets
Bookmark "Resource usage" Watch "Resource usage" New topic

Resource usage

Mark Leong
Ranch Hand

Joined: Dec 11, 2000
Posts: 60
Would appreciate if somebody could tell me if the follow code would use up server resouces excessively if there are 10 hits to the servlet per second.
How to improve the code?
------------------Code excerpt------------------------

//get db connection
Connection connection = null;
try {
connection = connectionPool.getConnection();
Statement statement = connection.createStatement();

QueryStatement = "select * from table1..............";
ResultSet RSResult = statement.executeQuery(QueryStatement);

while ({
//perform some action..........
QueryStatement = "delete from table1...........";
int DeleteResult = statement.executeUpdate(QueryStatement);
QueryStatement = "Update table2...............";
int Update = statement.executeUpdate(QueryStatement);
QueryStatement = "delete from table3............";
int Delete = statement.executeUpdate(QueryStatement);


finally {
try {
if (connection != null ) {
//close the connection no matter what;
catch (SQLException sqle){
} catch(SQLException sqle) {
System.err.println("Error connecting: " + sqle);

----------end of code excerpt ---------------------------
I agree. Here's the link:
subject: Resource usage
It's not a secret anymore!