Code example for Connection

Methods: commitprepareStatementsetAutoCommit

0
	@Override 
	public void saveUserConfig(String username, String config) {
		Connection conn = null;
		try { 
			conn = this.getConnection();
			conn.setAutoCommit(false);
			this.deleteUserConfigRecord(username, conn);
			this.addUserConfigRecord(username, config, conn);
			conn.commit();
		} catch (Throwable t) {
			this.processDaoException(t, "Error deleting user config by user " + username, "deleteUserConfig");
		} finally { 
			this.closeConnection(conn);
		} 
	} 
	 
	private void addUserConfigRecord(String username, String config, Connection conn) throws ApsSystemException {
		PreparedStatement stat = null;
		try { 
			stat = conn.prepareStatement(ADD_CONFIG);
			stat.setString(1, username);
			stat.setString(2, config);
			stat.executeUpdate();
		} catch (Throwable t) {
			this.processDaoException(t, "Error adding user config record", "addUserConfigRecord");
Experience pair programming with AI  Get Codota for Java