jQuery in Action, 3rd edition
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 (RSResult.next()){
//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: http://aspose.com/file-tools
subject: Resource usage
It's not a secret anymore!