List of usage examples for org.apache.commons.dbutils DbUtils commitAndCloseQuietly
public static void commitAndCloseQuietly(Connection conn)
Connection
then closes it, avoid closing if null and hide any SQLExceptions that occur. From source file:org.yukung.tasklet.logic.TaskTxLogic.java
/** * <p>/* ww w .j a va 2s. c o m*/ * ??? * </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>//from w w w .j av a 2 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>/* w w w .ja v a 2 s . c o 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); } }