List of usage examples for org.apache.commons.dbutils DbUtils rollbackAndCloseQuietly
public static void rollbackAndCloseQuietly(Connection conn)
Connection
then closes it, avoid closing if null and hide any SQLExceptions that occur. From source file:org.yukung.tasklet.logic.ActivityTxLogic.java
/** * <p>/* w w w . ja va 2 s . c o m*/ * ??? * </p> * * @param activity * Entity * @param category * Entity * @throws TaskletException * DB */ public void modify(Activity activity, Category category) throws TaskletException { Connection conn = null; try { conn = DaoFactory.getInstance().getConnection(); conn.setAutoCommit(false); activityDao.modifyTitle(conn, activity); activityDao.modifyIndexes(conn, activity, category); DbUtils.commitAndCloseQuietly(conn); } catch (SQLException e) { DbUtils.rollbackAndCloseQuietly(conn); throw new TaskletException(e.getMessage(), e); } }
From source file:org.yukung.tasklet.logic.ActivityTxLogic.java
/** * <p>// w w w .j a va 2 s. c o m * ???categories??indexes???? * </p> * * @param category * Entity * @throws TaskletException * DB */ public void delete(Category category) throws TaskletException { Connection conn = null; try { conn = DaoFactory.getInstance().getConnection(); conn.setAutoCommit(false); categoryDao.revertIndexes(conn, category); categoryDao.deleteCategory(conn, category); DbUtils.commitAndCloseQuietly(conn); } catch (SQLException e) { DbUtils.rollbackAndCloseQuietly(conn); throw new TaskletException(e.getMessage(), e); } }
From source file:org.yukung.tasklet.logic.TaskTxLogic.java
/** * <p>/*from w ww .j av a 2 s.c o m*/ * ??? * </p> * * @param task * Entity * @param memo * Entity * @exception DB? */ public void update(Task task, Memo memo) throws TaskletException { Connection conn = null; try { conn = DaoFactory.getInstance().getConnection(); conn.setAutoCommit(false); if (task.getStatus() == Status.FINISH) { // ?????? taskDao.completeTask(conn, task); int count = taskDao.getIncompleteCount(task.getActivityId()).intValue(); if (count == 0) { activityDao.completeActivity(conn, task.getActivityId()); } } else { // tasks? taskDao.updateTask(conn, task); activityDao.updateActivity(conn, task.getActivityId()); } // ???????? if (!memo.getContents().equals("")) { // ? int seq = getSeq(task); memo.setSeq(seq); // ?ID??ID?? memo.setTaskId(task.getId()); // memos? memoDao.addMemoToMemos(conn, memo); } DbUtils.commitAndCloseQuietly(conn); } catch (SQLException e) { DbUtils.rollbackAndCloseQuietly(conn); throw new TaskletException(e.getMessage(), e); } }
From source file:org.yukung.tasklet.logic.TaskTxLogic.java
/** * <p>//from w w w .j a v a 2 s.com * ??? * </p> * * @param activityId * @param checked * ?ID?? * @throws TaskletException * DB? */ public void complete(int activityId, String[] checked) throws TaskletException { Connection conn = null; try { conn = DaoFactory.getInstance().getConnection(); conn.setAutoCommit(false); taskDao.completeTasks(conn, checked); int count = taskDao.getIncompleteCount(activityId).intValue(); if (count == 0) { activityDao.completeActivity(conn, activityId); } DbUtils.commitAndCloseQuietly(conn); } catch (SQLException e) { DbUtils.rollbackAndCloseQuietly(conn); throw new TaskletException(e.getMessage(), e); } }
From source file:org.yukung.tasklet.logic.TaskTxLogic.java
/** * <p>/* w w w.ja v a2 s . co m*/ * ??? * </p> * * @param checked * ?ID?? * @exception TaskletException * DB? */ public void remove(String[] checked) throws TaskletException { Connection conn = null; try { conn = DaoFactory.getInstance().getConnection(); conn.setAutoCommit(false); memoDao.removeMemos(conn, checked); taskDao.removeTasks(conn, checked); DbUtils.commitAndCloseQuietly(conn); } catch (SQLException e) { DbUtils.rollbackAndCloseQuietly(conn); throw new TaskletException(e.getMessage(), e); } }
From source file:org.yukung.tasklet.logic.TaskTxLogic.java
/** * <p>/*from www .ja va 2 s . co m*/ * ????????????? * </p> * * @param activityId * @throws TaskletException * DB? */ public void delete(int activityId) throws TaskletException { Connection conn = null; try { conn = DaoFactory.getInstance().getConnection(); conn.setAutoCommit(false); deleteMemos(conn, activityId); deleteTasks(conn, activityId); activityDao.deleteIndexes(conn, activityId); activityDao.deleteActivities(conn, activityId); DbUtils.commitAndCloseQuietly(conn); } catch (SQLException e) { DbUtils.rollbackAndCloseQuietly(conn); throw new TaskletException(e.getMessage(), e); } }