Note that code should be enclosed in a try block, and that all database connections,
result sets, and statements must be closed in a finally block, as shown in the example below.
Failure to do this correctly can lead to connection pool leaks and eventually a hung system.
Javascript example:
var con = system.getDatabaseConnection("CONN1");
var stmt;
var rs;
try {
stmt = con.prepareStatement("select * from tab1");
rs = stmt.executeQuery();
while (rs.next()) {
var xx = rs.getString("col_name");
}
}
finally {
if (rs) rs.close();
if (stmt) stmt.close();
if (con) con.close();
}
Note that code should be enclosed in a
try
block, and that all database connections, result sets, and statements must be closed in afinally
block, as shown in the example below. Failure to do this correctly can lead to connection pool leaks and eventually a hung system.Javascript example: