J
Joshua
I have a database utility class with a number of static methods that
perform SQL actions. Amongst the paramaters passed to a static method
is a connection object. The database utility static method creates a
statement from the connection object that is passed in, performs an
SQL query on that statement, and returns a ResultSet. Originally this
utility method was calling the close() method on the statement object
for tidyness. Then I realised the ResultSet object was consequently
closed and therefore could not be used outside of the utility method.
The first question I have is if I call the close() method of the
ResultSet object will it close the statement object created in the
utility method?
Java docs suggests so -
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/ResultSet.html#close()
..
If this is the case then I will call ResultSet.close() in the method
calling the utility method after it has done it's job with the
returned data.
The second question I have is I'm wondering how others have best
designed a database utility class, and if I can maybe improve my
design.
perform SQL actions. Amongst the paramaters passed to a static method
is a connection object. The database utility static method creates a
statement from the connection object that is passed in, performs an
SQL query on that statement, and returns a ResultSet. Originally this
utility method was calling the close() method on the statement object
for tidyness. Then I realised the ResultSet object was consequently
closed and therefore could not be used outside of the utility method.
The first question I have is if I call the close() method of the
ResultSet object will it close the statement object created in the
utility method?
Java docs suggests so -
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/ResultSet.html#close()
..
If this is the case then I will call ResultSet.close() in the method
calling the utility method after it has done it's job with the
returned data.
The second question I have is I'm wondering how others have best
designed a database utility class, and if I can maybe improve my
design.