// 修改HAB值 public void changeHAB(Context context) { List errList = context.errList; HashMap outputMap = new HashMap(); if (errList.isEmpty()) { SqlMapClient sqlMapper = DataAccessor.getSession(); try { sqlMapper.startTransaction(); sqlMapper.update("activitiesLog.modifyHAB", context.getContextMap()); sqlMapper.commitTransaction(); } catch (SQLException e) { e.printStackTrace(); LogPrint.getLogStackTrace(e, logger); errList.add(e); } finally { try { sqlMapper.endTransaction(); } catch (SQLException e) { e.printStackTrace(); LogPrint.getLogStackTrace(e, logger); errList.add(e); } } } else { outputMap.put("errList", errList); Output.jspOutput(outputMap, context, "/error.jsp"); } if (errList.isEmpty()) { // } else { outputMap.put("errList", errList); Output.jspOutput(outputMap, context, "/error.jsp"); } }
@Override public void viewList(String type) throws SQLException { if (type.equals("Banner")) { SqlMapClient ibatis = Mapper.getSqlMapper(); bannerList = ibatis.queryForList("selectBannerList"); } }
/** * 데이터 수정. * * @param userDB * @param title * @param desc * @param cronExp * @param listSchedule * @return * @throws Exception */ public static ScheduleMainDAO modifySchedule( final UserDBDAO userDB, ScheduleMainDAO scheduleDao, List<ScheduleDAO> listSchedule) throws Exception { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB()); sqlClient.update("scheduleMainUpdate", scheduleDao); // 기존 데이터를 삭제합니다. sqlClient.update("deleteSchedule", scheduleDao.getSeq()); // save schedule for (ScheduleDAO scheduleDAO : listSchedule) { scheduleDAO.setSchedule_main_seq(scheduleDao.getSeq()); ScheduleDAO retScheduleDAO = (ScheduleDAO) sqlClient.insert("scheduleInsert", scheduleDAO); // sql String[] sqls = SQLUtil.makeResourceDataArays(scheduleDAO.getSql()); ScheduleDetailDAO detailDao = null; for (String sql : sqls) { detailDao = new ScheduleDetailDAO(); detailDao.setSchedule_seq(retScheduleDAO.getSeq()); detailDao.setDatas(sql); sqlClient.insert("scheduleDetailInsert", detailDao); } } return scheduleDao; }
public ArrayList<ArrayList> moveRepositories() { ArrayList<ArrayList> res = new ArrayList<ArrayList>(0); int old_prj = (Integer) idch.getProjectID().get(0).get(0); int new_prj = (Integer) idch.getProjectID().get(0).get(1); try { List lst = client.queryForList("GetRepositoriesForIssue", new ParamHelper(s_db, old_prj)); for (int i = 0; i < lst.size(); ++i) { Repository r = (Repository) lst.get(i); r.setProject_id(new_prj); r.setT_db(t_db); client.insert("insertRepository", r); res.add(new ArrayList(0)); int newID = (Integer) client.queryForObject("LastInsertId", new ParamHelper(t_db, "repositories")); res.get(res.size() - 1).add(r.getId()); res.get(res.size() - 1).add(newID); } } catch (Exception e) { logger.error("in moveRepositories", e); JOptionPane.showMessageDialog( null, e.getMessage() + e.getStackTrace(), "Беда!", JOptionPane.ERROR_MESSAGE); // e.printStackTrace(); } return res; }
public ArrayList<ArrayList> moveChanges() { ArrayList<ArrayList> res = new ArrayList<ArrayList>(0); try { for (int i = 0; i < idch.getChangesetID().size(); ++i) { Integer old_ch = (Integer) idch.getChangesetID().get(i).get(0); Integer new_ch = (Integer) idch.getChangesetID().get(i).get(1); List lst = client.queryForList("GetChanges", new ParamHelper(s_db, old_ch)); for (int j = 0; j < lst.size(); ++j) { Change c = (Change) lst.get(j); c.setT_db(t_db); c.setChangeset_id(new_ch); client.insert("insertChange", c); res.add(new ArrayList(0)); int newID = (Integer) client.queryForObject("LastInsertId", new ParamHelper(t_db, "changes")); res.get(res.size() - 1).add(c.getId()); res.get(res.size() - 1).add(newID); } } } catch (Exception e) { logger.error("in moveChanges", e); JOptionPane.showMessageDialog( null, e.getMessage() + e.getStackTrace(), "Беда!", JOptionPane.ERROR_MESSAGE); // e.printStackTrace(); } return res; }
public User checkUser(String username, String password) { // int size = 0; // User user = new User(); // user.setUsername(username); // user.setPassword(password); // this.init(); // try // { // if (null != sqlMap.queryForList("checkUser", user) && // sqlMap.queryForList("checkUser", user).size() != 0) // { // return (User) sqlMap.queryForList("checkUser", user).get(0); // } // } // catch(SQLException e) // { // log.debug("Error in UserDAO.java:" +e); // e.printStackTrace(); // } // return null; User user = new User(); user.setUsername(username); user.setPassword(password); try { if (0 != sqlMapClient.queryForList("checkUser", user).size()) { return (User) sqlMapClient.queryForList("checkUser", user).get(0); } } catch (SQLException sqle) { sqle.printStackTrace(); } return null; }
/* (non-Javadoc) * @see com.hangum.tadpole.rdb.core.editors.objects.table.scripts.RDBDDLScript#getTableScript(com.hangum.tadpole.dao.mysql.TableDAO) */ @Override public String getTableScript(TableDAO tableDAO) throws Exception { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); Map srcList = (HashMap) client.queryForObject("getTableScript", tableDAO.getName()); return "" + srcList.get("Create Table"); }
public List<NoticeVO> getNoticeRange(HashMap<String, Object> range) throws Exception { SqlMapClient sqlmap = IbatisUtil.getSqlmap(); List<NoticeVO> list = sqlmap.queryForList("getNoticeRange", range); return list; }
public NoticeVO getTitleInfo(int no) throws Exception { SqlMapClient sqlmap = IbatisUtil.getSqlmap(); NoticeVO notice = (NoticeVO) sqlmap.queryForObject("getTitleInfo", no); return notice; }
public int getTotalRow(int no) throws Exception { SqlMapClient sqlmap = IbatisUtil.getSqlmap(); int totalRow = (Integer) sqlmap.queryForObject("getTotalRow", no); return totalRow; }
/** * mongodb update * * @param txtLimitCount * @param txtMacCount * @param txtFindPage * @param txtResultPage * @throws Exception */ public static void updateMongoDBUserInfoData( String txtLimitCount, String txtMacCount, String txtFindPage, String txtResultPage) throws Exception { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB()); UserInfoDataDAO userInfoData = new UserInfoDataDAO(); userInfoData.setUser_seq(SessionManager.getSeq()); // MONGO_DEFAULT_LIMIT userInfoData.setName(PreferenceDefine.MONGO_DEFAULT_LIMIT); userInfoData.setValue0(txtLimitCount); sqlClient.update("userInfoDataUpdate", userInfoData); // $NON-NLS-1$ // MONGO_DEFAULT_MAX_COUNT userInfoData.setName(PreferenceDefine.MONGO_DEFAULT_MAX_COUNT); userInfoData.setValue0(txtMacCount); sqlClient.update("userInfoDataUpdate", userInfoData); // $NON-NLS-1$ // MONGO_DEFAULT_FIND userInfoData.setName(PreferenceDefine.MONGO_DEFAULT_FIND); userInfoData.setValue0(txtFindPage); sqlClient.update("userInfoDataUpdate", userInfoData); // $NON-NLS-1$ // MONGO_DEFAULT_RESULT userInfoData.setName(PreferenceDefine.MONGO_DEFAULT_RESULT); userInfoData.setValue0(txtResultPage); sqlClient.update("userInfoDataUpdate", userInfoData); // $NON-NLS-1$ }
public int updateTqcBatch(String statment, Object obj) throws DataAccessIntegrityViolationException, DataAccessException { SqlMapClient sqlmapclient = this.getSqlMapClient(); int o = 0; List<TqcAlarm> list = null; try { if (null == obj) { throw new DataAccessException("the obj value is null"); } if (!(obj instanceof List)) { throw new UnsupportedOperationException("the obj should be List instance"); } else { list = (List<TqcAlarm>) obj; } // 开启批处理 sqlmapclient.startBatch(); for (TqcAlarm alarm : list) { o = getSqlMapClientTemplate().update(statment, alarm); } // 批处理执行 sqlmapclient.executeBatch(); return o; } catch (SQLException e) { throw new DataAccessException(e); } catch (Exception e) { throw new DataAccessException(e); } }
@SuppressWarnings("unchecked") public static void main(String[] args) throws IOException { String config = "sqlMapConfig.xml"; Reader reader = Resources.getResourceAsReader(config); SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader); ClusterViewModel cViewModel = new ClusterViewModel(); cViewModel.setId(Rpid.generate()); try { sqlMap.insert("insertClusterViewModel", cViewModel); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } List<ClusterViewModel> list; try { list = sqlMap.queryForList("checkFromCluster"); for (ClusterViewModel clusterViewModel : list) { System.out.println(clusterViewModel); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
// 연수행사(답글) 뷰페이지 @RequestMapping("/trainingEventRepView.do") public String trainingEventRepView(HttpServletRequest request1, HttpSession session) throws SQLException { // -------------------------------------------------------------------------------------------------------------------// /*seq, currentPage, searchingNow (+ searchType, userinput) 의 변수값을 초기화 한다.*/ int seq = Integer.parseInt(request1.getParameter("seq")); if (null == request1.getParameter("currentPage")) { currentPage = 1; } else { currentPage = Integer.parseInt(request1.getParameter("currentPage")); } searchingNow = Integer.parseInt(request1.getParameter("searchingNow")); // 검색일 경우 존재하는 변수 초기화 if (searchingNow == 1) { searchType = request1.getParameter("searchType"); userinput = request1.getParameter("userinput"); // 뷰로 아래의 변수 3개를 보내는 이유는 // 목록을 클릭했을 때 다시 검색중인 리스트로 돌아가기 위함이다. +위의 currentPage와 함께! request1.setAttribute("searchType", searchType); request1.setAttribute("userinput", userinput); request1.setAttribute("searchingNow", 1); } else { // 검색중이 아닌경우에는 아래의 변수값이 존재하지 않음을 의미하는 0을 초기화 시켜서 해당 jsp 로 보낸다. request1.setAttribute("searchType", 0); request1.setAttribute("userinput", 0); request1.setAttribute("searchingNow", 0); } // .-------------------------------------------------------------------------------------------------------------------// // -------------------------------------------------------------------------------------------------------------------// /*조회수 +1 하기*/ // 조회수 +1 시킬 레코드를 불러온다. resultClass = (TrainingEventDTO) sqlMapper.queryForObject("TrainingEvent.selectTrainingEventOne", seq); // 뷰페이지의 조회수를 +1 업데이트 paramClass.setSeq(seq); paramClass.setHits(resultClass.getHits() + 1); sqlMapper.update("TrainingEvent.updateHits", paramClass); // .-------------------------------------------------------------------------------------------------------------------// // 뷰페이지에 보여질 레코드 1개를 get resultClass = (TrainingEventDTO) sqlMapper.queryForObject("TrainingEvent.selectTrainingEventOne", seq); request1.setAttribute("seq", seq); request1.setAttribute("currentPage", currentPage); request1.setAttribute("searchingNow", searchingNow); request1.setAttribute("resultClass", resultClass); // 레코드1개 return "/view/menu7/trainingEvent/trainingEventRepView.jsp"; }
public boolean deleteRetroDocument(Integer documentId) throws SQLException { SqlMapClient sqlMapClient = getSqlMapClient(); sqlMapClient.startTransaction(); boolean b = sqlMapClient.delete("rd.deleteDocument", documentId) == 1 && sqlMapClient.delete("rd.deleteAllInvitations", documentId) == 1; sqlMapClient.commitTransaction(); return b; }
public static void main(String[] args) throws IOException, SQLException { String resource = "ibatis/sqlmap-config.xml"; Reader reader = Resources.getResourceAsReader(resource); SqlMapClient sqlmap = SqlMapClientBuilder.buildSqlMapClient(reader); HashMap<String, String> param = new HashMap<String, String>(); param.put("a", "1"); Object obj = sqlmap.queryForObject("testSelectAs", param); System.out.println(obj); }
/* (non-Javadoc) * @see com.hangum.tadpole.rdb.core.editors.objects.table.scripts.RDBDDLScript#getProcedureScript(com.hangum.tadpole.dao.mysql.ProcedureFunctionDAO) */ @Override public String getProcedureScript(ProcedureFunctionDAO procedureDAO) throws Exception { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); Map srcList = (HashMap) client.queryForObject("getProcedureScript", procedureDAO.getName()); String strSource = "" + srcList.get("Create Procedure"); strSource = StringUtils.substringAfterLast(strSource, "PROCEDURE"); return "CREATE PROCEDURE " + strSource; }
/** * schedule result * * @param seq * @param isResult * @param msg */ public static void saveScheduleResult(int seq, boolean isResult, String msg) throws Exception { ScheduleResultDAO dao = new ScheduleResultDAO(); dao.setSchedule_main_seq(seq); dao.setResult( isResult ? PublicTadpoleDefine.YES_NO.YES.name() : PublicTadpoleDefine.YES_NO.NO.name()); dao.setDescription(msg); SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB()); sqlClient.insert("scheduleResultInsert", dao); }
/** * general 정보의 export delimit을 저장합니다. * * @param sessionTimeOut * @throws Exception */ public static void updateGeneralExportDelimitData(String delimit) throws Exception { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB()); UserInfoDataDAO userInfoData = new UserInfoDataDAO(); userInfoData.setUser_seq(SessionManager.getSeq()); // select 제한 갯수 userInfoData.setName(PreferenceDefine.EXPORT_DILIMITER); userInfoData.setValue0(delimit); sqlClient.update("userInfoDataUpdate", userInfoData); // $NON-NLS-1$ }
/** * general 정보의 session time을 저장합니다. * * @param sessionTimeOut * @throws Exception */ public static void updateGeneralUserInfoData(String sessionTimeOut) throws Exception { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB()); UserInfoDataDAO userInfoData = new UserInfoDataDAO(); userInfoData.setUser_seq(SessionManager.getSeq()); // select 제한 갯수 userInfoData.setName(PreferenceDefine.SESSION_DFEAULT_PREFERENCE); userInfoData.setValue0(sessionTimeOut); sqlClient.update("userInfoDataUpdate", userInfoData); // $NON-NLS-1$ }
/** * default home page * * @param use * @throws Exception */ public static void updateDefaultHomePageUse(String use) throws Exception { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB()); UserInfoDataDAO userInfoData = new UserInfoDataDAO(); userInfoData.setUser_seq(SessionManager.getSeq()); // select 제한 갯수 userInfoData.setName(PreferenceDefine.DEFAULT_HOME_PAGE_USE); userInfoData.setValue0(use); sqlClient.update("userInfoDataUpdate", userInfoData); // $NON-NLS-1$ }
/** * sequenc * * @param dao * @return * @throws TadpoleSQLManagerException, SQLException */ public static TadpoleSequenceDAO getSequence(TadpoleSequenceDAO dao) throws TadpoleSQLManagerException, SQLException { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB()); dao = (TadpoleSequenceDAO) sqlClient.queryForObject("lastSequene", dao); dao.setNo(dao.getNo() + 1); sqlClient.update("updateSequence", dao); return dao; }
/** * 마지막 실행했떤 쿼리 100개를 리턴합니다. * * @param user_seq * @param dbSeq * @return * @throws Exception */ public static List<SQLHistoryDAO> getExecuteQueryHistory(int user_seq, int dbSeq, String filter) throws Exception { List<SQLHistoryDAO> returnSQLHistory = new ArrayList<SQLHistoryDAO>(); Map<String, Object> queryMap = new HashMap<String, Object>(); queryMap.put("user_seq", user_seq); queryMap.put("db_seq", dbSeq); queryMap.put("filter", "%" + filter + "%"); queryMap.put("count", 50); SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB()); List<java.util.Map> listResourceData = sqlClient.queryForList("getExecuteQueryHistory", queryMap); for (Map resultMap : listResourceData) { int seq = (Integer) resultMap.get("executed_sql_resource_seq"); Long startdateexecute = 0l; // This case sqlite if (resultMap.get("startdateexecute") instanceof Long) { startdateexecute = (Long) resultMap.get("startdateexecute"); // This case mysql } else { startdateexecute = ((Timestamp) resultMap.get("startdateexecute")).getTime(); } String strSQLText = (String) resultMap.get("datas"); Long enddateexecute = 0l; // This case sqlite if (resultMap.get("enddateexecute") instanceof Long) { enddateexecute = (Long) resultMap.get("enddateexecute"); // This case mysql } else { enddateexecute = ((Timestamp) resultMap.get("enddateexecute")).getTime(); } String strMessage = (String) resultMap.get("message"); int row = (Integer) resultMap.get("row"); String result = (String) resultMap.get("result"); SQLHistoryDAO dao = new SQLHistoryDAO( new Timestamp(startdateexecute), strSQLText, new Timestamp(enddateexecute), row, result, strMessage); dao.setSeq(seq); returnSQLHistory.add(dao); } return returnSQLHistory; }
/** * table의 컬럼 정보를 가져옵니다. * * @param strTBName * @return * @throws Exception */ public List<TableColumnDAO> getColumns(String strTBName) throws Exception { Map<String, String> param = new HashMap<String, String>(); param.put("db", userDB.getDb()); // $NON-NLS-1$ param.put("table", strTBName); // $NON-NLS-1$ if (userDB.getDBDefine() == DBDefine.TAJO_DEFAULT) { return new TajoConnectionManager().tableColumnList(userDB, param); } else { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB); return sqlClient.queryForList("tableColumnList", param); // $NON-NLS-1$ } }
/* (non-Javadoc) * @see com.hangum.tadpole.rdb.core.editors.objects.table.scripts.RDBDDLScript#getFunctionScript(com.hangum.tadpole.dao.mysql.ProcedureFunctionDAO) */ @Override public String getFunctionScript(ProcedureFunctionDAO functionDAO) throws Exception { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); StringBuilder result = new StringBuilder(""); Map srcList = (HashMap) client.queryForObject("getFunctionScript", functionDAO.getName()); String strSource = "" + srcList.get("Create Function"); strSource = StringUtils.substringAfterLast(strSource, "FUNCTION"); return "CREATE FUNCTION " + strSource; }
/* (non-Javadoc) * @see com.hangum.tadpole.rdb.core.editors.objects.table.scripts.RDBDDLScript#getViewScript(java.lang.String) */ @Override public String getViewScript(String strName) throws Exception { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); StringBuilder result = new StringBuilder(""); Map srcList = (HashMap) client.queryForObject("getViewScript", strName); String strSource = "" + srcList.get("Create View"); strSource = StringUtils.substringAfterLast(strSource, "VIEW"); return "CREATE VIEW " + strSource; }
/* (non-Javadoc) * @see com.hangum.tadpole.rdb.core.editors.objects.table.scripts.RDBDDLScript#getTriggerScript(com.hangum.tadpole.dao.mysql.TriggerDAO) */ @Override public String getTriggerScript(TriggerDAO triggerDAO) throws Exception { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); StringBuilder result = new StringBuilder(""); Map srcList = (HashMap) client.queryForObject("getTriggerScript", triggerDAO.getTrigger()); String strSource = "" + srcList.get("SQL Original Statement"); strSource = StringUtils.substringAfterLast(strSource, "TRIGGER"); return "CREATE TRIGGER " + strSource; }
/** * 方法用途和描述: 查询域用户 * * @return * @author chenliang 新增日期:2013-6-24 * @since system_center_sdk */ public List<DomUserEntity> listEntity() { try { SqlMapClient sqlmap = IbatisClientManager.getSqlMapClient(); List<DomUserEntity> domUserList = sqlmap.queryForList(DomUserEntity.class.getName() + ".queryAll"); return domUserList; } catch (SQLException e) { e.printStackTrace(); LOGGER.error("listEntity error", e); } return null; }
/** * resource data * * @param userDBResource * @param contents * @throws Exception */ private static void insertResourceData(ExecutedSqlResourceDAO userDBResource, String contents) throws Exception { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB()); // content data를 저장합니다. ExecutedSqlResourceDataDAO dataDao = new ExecutedSqlResourceDataDAO(); dataDao.setExecuted_sql_resource_seq(userDBResource.getSeq()); String[] arrayContent = SQLUtil.makeResourceDataArays(contents); for (String content : arrayContent) { dataDao.setDatas(content); sqlClient.insert("userExecuteSQLResourceDataInsert", dataDao); // $NON-NLS-1$ } }
/* (non-Javadoc) * @see com.hangum.tadpole.rdb.core.editors.objects.table.scripts.RDBDDLScript#getTriggerScript(com.hangum.tadpole.dao.mysql.TriggerDAO) */ @Override public String getTriggerScript(TriggerDAO triggerDAO) throws Exception { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); StringBuilder result = new StringBuilder(""); result.append("/* DROP PROCEDURE " + triggerDAO.getName() + "; */ \n\n"); List<String> srcProcList = client.queryForList("getTriggerScript", triggerDAO.getName()); for (int i = 0; i < srcProcList.size(); i++) { result.append(srcProcList.get(i)); } return result.toString(); }