{{theTime}}

Search This Blog

Total Pageviews

JDBC4.1 try-with-resource statement

JDBC4.1 supports try-with-resource statement.
 - Try-with-resource Automatically close connection, statement and resultset regardless of sqlexception 


    public static void fetchData(Connection conn) throws SQLException {
        final String qry = "select rank from student" ;
        try(PreparedStatement stmt = conn.prepareStatement(qry)) {
            ResultSet rs = stmt.executeQuery() ;
            while(rs.next()){
                System.out.println(rs.getInt(1)) ;
            }
        }        
    }

No comments:

java.lang.NoSuchFieldError: Class com.sun.tools.javac.tree.JCTree$JCImport

SpringBoot Error: java.lang.NoSuchFieldError: Class com.sun.tools.javac.tree.JCTree$JCImport does not have member field 'com.sun.tools.j...