Will the connection.close() and statement.close() ever be called???
I have a code and question on it..
Code:
import java.sql.*;
public class ResultSet_lastrow {
public static int last_row() {
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
try {
connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:Oracle9i", "rms", "stephen00.rms");
statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
resultSet = statement.executeQuery("select * from rms_accountstore");
resultSet.last();
[COLOR="Red"]return resultSet.getRow();[/COLOR]
} catch (SQLException sqlException) {
sqlException.printStackTrace();
} finally {
try {
statement.close();
connection.close();
} catch (Exception exception) {
exception.printStackTrace();
System.exit(1);
}
}
return 0;
}
public static void main(String[] args) {
ResultSet_lastrow r = new ResultSet_lastrow();
System.out.println(ResultSet_lastrow.last_row());
}
}
The colored portion of the snippet returns a value.. I have a question that whether the connection.close() and statement.close() methods will ever be called???
i mean the return statements pass the control to the calling methods then in that cases what will be the exact behavior of this program. please suggest