Would there be any effect if I close my Connection object once I got my ResultSet?
Connection con= DriverManager.getConnection();
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(query);
con.close();
Further to this I use my rs object and I feel there will not be any impact on it. Because ResultSet and Statement are in connection with each other.
You can’t access the resultset soon after you close the connection to the database. Because, when you use
resultset.next()method, it will send a request to the database in order to fetch the next record; but physically the connection has been closed. So, anExceptionwill be thrown by your statementresultset.next().