Hello-
What are the implications of not closing a Statement, but rather closing the ResultSet that comes from the Statement? The reason is my class that handles the database connection and querying just returns a result set. For example, if I have the following:
String query = "Select * from test_table";
ResultSet rs = DB.DBQuery(query);
. . . .
rs.close();
In class DB (try catch blocks left off...):
public ResultSet DBQuery(String query) {
Statement st;
// get connection...
ResultSet rs = st.execute(query);
return rs;
}
Notice the statment st is not closed in the DB class. However, it only has method scope. Will this cause a problem? I am using
JDBC:ODBC bridge with Access.
Is a better design to not return a ResultSet, but rather put the ResultSet data into a HashTable or something similar and pass back the HashTable, that way the statement (and thus the resultset) can be closed in the database class?
Thanks for the help
Brian