File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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 ---------------------------
jQuery in Action, 3rd edition
subject: Resource usage
It's not a secret anymore!