> Does anyone know how to close a ResultSet?
Note that this isn't a Tomcat question: there are newsgroups and mailing
lists specifically for JDBC.
> Heres my code:
> public String getName() throws Exception {
> Statement statement = connection.createStatement();
> int myInt = 1;
> ResultSet rs = statement.executeQuery("SELECT Name"+
> " FROM nameAddress" +
> " WHERE ID = ("+
> myInt + ")");
try
{
> rs.next();
> String myString = rs.getString("Name");
> //change the resultSet to a string
> //so it can be used by the jsp page
> return myString;
}
finally
{
rs.close();
statement.close();
}
> }
To be super-cautious, include createStatement() and executeQuery() in the
"try" block, and surround the calls to close() with try/catch blocks.
-- Bill K.