The finally block may not always execute; consider the following code.
public class Tester { public static void main(String[] args) { try { System.out.println("The main method has run"); System.exit(1); } catch (Exception e) { e.printStackTrace(); } finally { System.out.println("The finally block has run"); } } }
In your case, I would suggest wrapping the code inside the finally block in try / catch, as this code is likely to throw an exception.
} catch (SQLException sqle) { sqle.printStackTrace(); } finally { try { cs.close(); rs.close(); } catch (Exception e) {
nomadus Dec 09 '16 at 6:01 2016-12-09 06:01
source share