Code example for PreparedStatement

Methods: close

0
 
 
    public static Object execute(PreparedStatement pstmt, PreparedStatementCallback pstmtCallBack) {
        try { 
            if (pstmtCallBack != null && pstmt != null) {
                return pstmtCallBack.doInPreparedStatement(pstmt);
            } 
        } 
        catch (SQLException e) {
            log.error("doInPreparedStatement failed", e);
        } 
        finally { 
            close(pstmt);
        } 
        return null; 
    } 
 
 
    public static Object execute(ResultSet rs, ResultSetCallback rsCallback) {
        try { 
            if (rsCallback != null && rs != null) {
                return rsCallback.doInResultSet(rs);
            } 
        } 
        catch (SQLException e) {
            log.error("doInResultSet failed", e);
        } 
        finally { 
            close(rs);
        } 
        return null; 
    } 
 
 
    public static void close(PreparedStatement preparedStatement) {
        if (preparedStatement != null) {
            try { 
                preparedStatement.close();
            } 
            catch (SQLException e) {
                log.error("Close PreparedStatement failed", e);
            }