/***********************************************************************************
 * @@ Program Name : HttpDeptList.java Description : 기관에속한 부서들의 목록 Author : 강원중 Create Date : 2003-12-16 History :
 * @@
 ***********************************************************************************/

package kr.co.kihyun.beans.user;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import kr.co.kihyun.db.DBManager;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SelectMaxId extends DBManager {

    private  List<String> recogid;
    private ResultSet rs = null;
   	private static final Logger LOG = LoggerFactory.getLogger(SelectMaxId.class);

   	private String[] ID = null;
   	private String[] RECOG = null;
   	private String[] RECOG_NUM = null;
   	private String[] RECOG_USER_ID = null;
   	private String[] REPORT_ID = null;
   	private String[] RECOGFLAG = null;
    private Long MAXID = null;

   public SelectMaxId(Long strReportID) {
       StringBuilder sql = new StringBuilder(250);
       int count = 0;

		try {

            sql.append("SELECT MAX(ID) FROM MOUMI_REPOADM WHERE REPORT_ID = '"+strReportID+"' ");
			rs = execQuery(sql);
			if (rs != null) {
				rs.last();
				count = rs.getRow();
				rs.beforeFirst();
			} else {
				return;
			}

			for (int i = 0; rs.next(); i++) {
                MAXID = rs.getLong(1);

			}

          //System.out.println(sql);

		} catch (SQLException sqlEx) {
			LOG.error("\nSQLState - {}\nMySQL Error Code - {}\nmessage - {}\nsql - {}",
			new Object[] { sqlEx.getSQLState(), sqlEx.getErrorCode(), sqlEx.getMessage()});
			throw new RuntimeException(sqlEx);
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		} finally {
                    try {
                        if (con != null)
                            con.close();
                    } catch (SQLException ex) {
                        //31.오류 상황 대응 부재_CWE-390 Add by YOUNGJUN,CHO
                        ex.printStackTrace();
                        //++++++++++++++++++++++++++++++++++++++++++++++++
                    }
                    try {
                        if (pstmt != null)
                        	pstmt.close();
                    } catch (SQLException ex) {
                        //31.오류 상황 대응 부재_CWE-390 Add by YOUNGJUN,CHO
                        ex.printStackTrace();
                        //++++++++++++++++++++++++++++++++++++++++++++++++
                    }
                    try {
                        if (rs != null)
                            rs.close();
                    } catch (SQLException ex) {
                        //31.오류 상황 대응 부재_CWE-390 Add by YOUNGJUN,CHO
                        ex.printStackTrace();
                        //++++++++++++++++++++++++++++++++++++++++++++++++
                    }
		}
    }

    public Long getMaxId(){
        return MAXID;
    }


}
