Code example for Connection

Methods: commit

0
 
	protected void insert(Connection connection, boolean commit) throws UserStoreException {
		PreparedStatement stmt = null;
		ResultSet res = null;
		try { 
			insert(stmt, res, connection);
		} catch (SQLException e) {
			String error = "Insertion faild for the permission";
			log.error(error + e.getMessage());
			throw new UserStoreException(error + e.getMessage());
 
		} finally { 
			if (!commit) {
				DatabaseUtil.closeAllConnections(null, res, stmt);
			} else { 
				commitConnection(connection);
				DatabaseUtil.closeAllConnections(connection, res, stmt);
			} 
		} 
 
	} 
 
	protected abstract void insert(PreparedStatement stmt, ResultSet res, Connection connection)
	                                                                                            throws SQLException, 
	                                                                                            UserStoreException; 
 
	protected abstract void update(Connection connection, boolean commit) throws UserStoreException;
 
	protected abstract void delete(Connection connection, boolean commit) throws UserStoreException;
 
	protected abstract void saveDependentModules(Connection connection, boolean commit)
	                                                                                   throws UserStoreException; 
 
	public abstract List<? extends GenericDAO> load(Connection connection)
	                                                                      throws UserStoreException; 
 
	public List<? extends GenericDAO> load(Connection connection, boolean closeConnection)
	                                                                                      throws UserStoreException { 
		throw new UserStoreException("Need implementation"); 
	} 
 
	protected void resetAppendTxt() { 
		appendTxt = WHERE;
	} 
 
	protected void commitConnection(Connection connection) throws UserStoreException {
		try { 
			connection.commit();
		} catch (SQLException e) {
			String error = "Error commiting changes to the database " + e.getMessage();
			log.error(error);
			throw new UserStoreException(error, e);
		}