Click to See Complete Forum and Search --> : Tomcat problem
devteam
11-07-2005, 12:11 AM
i am using tomcat 4.12 and sql server 2000...
while multiple users accessing our application, each page takes time to load...
i have checked task manager. before loading the page, the tomcat usage is 70 MB, once the page is loaded the usage is keep on increasing...
after unloading the page, tomcat usage is not decreased..
what should i do for that ? how to check the sql server open cursor?
aniseed
11-07-2005, 12:43 AM
how to check the sql server open cursor?
One way of ensuring that all cursors are taken care of, is to call the close() method on ResultSet, Statement (includes PreparedStatement and CallableStatement) and Connection objects. generally, calling close() on Connection objects ensures that the DB cursors are closed but it is good practice to close the statements and resultsets when they are not required any further in the code. This releases some of the system resources.
I usually follow an approach where a DBUtil class (utility class for database related stuff) is used to close the resources
import java.sql.*;
public class DBUtil {
public static void close(Connection conn) {
try {
if(conn != null && !conn.isClosed()) conn.close();
} catch(SQLException sqle) {
// Log the exception.
}
}
public static void close(Statement stmt) {
try {
if(stmt != null) stmt.close();
} catch(SQLException sqle) {
// Log the exception.
}
}
public static void close(ResultSet rs) {
try {
if(rs != null) rs.close();
} catch(SQLException sqle) {
// Log the exception.
}
}
/* Other utility methods */
}
The static overloaded close() methods are called in a finally block in the code to ensure that all the resources get closed before the code block completes execution.
devx.com
Copyright Internet.com Inc. All Rights Reserved