网易博客| 空间服务| 博客圈| 搜索圈子
正在加载用户信息...
con.prepareStatement(sql)
2008年06月05日 15:37:31 作者: 不淨之心
here is an example:

public boolean chkDuplicate(VoGroup group) {
    ResultSet rs=null;
    Database db=null;
    Connection con=null;
    PreparedStatement pstmt=null;
try {
    db = com.asl.hrmis.comm.CommonUtils.getDataBase();
    con = db.getRawJdbcConnection();
    String sql ="select count(*) from HRSEC_GROUP ";    
    sql += "where group_id <> ? ";
    sql += "and group_code = ? ";
            
    pstmt = con.prepareStatement(sql);
    pstmt.setLong(1,group.getGroupId());
    pstmt.setString(2,group.getGroupCode());
    rs = pstmt.executeQuery();
    while(rs.next()) {
        if (rs.getInt(1) > 0) {
            return true;
        }
    }
} catch (DatabaseException e) {
    e.printStackTrace();
} catch (SQLException e) {
    e.printStackTrace();
}finally {
    if(rs!=null){
        try {rs.close();} catch (Exception e) {}
    }
    if(pstmt!=null){
        try {pstmt.close();} catch (Exception e) {}
    }
    if(con!=null){
        try {con.close();} catch (Exception e) {}
    }
    if(db!=null){
        db.close();
    }
}
    return false;
}

正在加载博主信息...
正在加载博主日志...
圈内相关日志
正在加载分类相关日志...