private void cleanTransferHistory() { PreparedStatement preparedStatement = null; Connection connection = null; try { connection = dataSource.getConnection(); connection.setAutoCommit(false); preparedStatement = connection.prepareStatement("DELETE FROM TransferHistory"); preparedStatement.executeUpdate(); preparedStatement = connection.prepareStatement("ALTER TABLE TransferHistory AUTO_INCREMENT = 1"); preparedStatement.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (connection != null) { connection.setAutoCommit(true); } if (preparedStatement != null) { preparedStatement.close(); } } catch (SQLException e) { e.printStackTrace(); } } cleanSession(); }
private void cleanSession() { PreparedStatement preparedStatement = null; try { preparedStatement = dataSource.getConnection().prepareStatement("DELETE FROM Session"); preparedStatement.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (preparedStatement != null) { preparedStatement.close(); } } catch (SQLException e) { e.printStackTrace(); } } cleanUsers(); }