aspose file tools*
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
Author

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?
Thanks.
------------------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 (RSResult.next()){
//perform some action..........
}
RSResult.close();
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);

connection.close();
connectionPool.free(connection);

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

----------end of code excerpt ---------------------------
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Resource usage