Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void deleteFonesPorUser(Long idUser) {
- deleteFones(idUser);
- deleteUser(idUser);
- }
- private void deleteFones(Long idUser) {
- try {
- String fone = "DELETE FROM telefoneuser WHERE usuariopessoa = " + idUser;
- PreparedStatement preparedStatement = connection.prepareStatement(fone);
- preparedStatement.executeUpdate();
- connection.commit();
- } catch (Exception e) {
- System.out.println(e);
- try {
- connection.rollback();
- } catch (Exception e2) {
- System.out.println(e2);
- }
- }
- }
- private void deleteUser(Long idUser) {
- try {
- String user = "DELETE FROM userposjava WHERE id = " + idUser;
- PreparedStatement preparedStatement = connection.prepareStatement(user);
- preparedStatement.executeUpdate();
- connection.commit();
- } catch (Exception e) {
- System.out.println(e);
- try {
- connection.rollback();
- } catch (Exception e2) {
- System.out.println(e2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement