Created
May 8, 2023 14:07
-
-
Save jeffersonchaves/75c0bcd9031014c137c701e645afedb8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.edu.ifpr.persistproject.repository; | |
import br.edu.ifpr.persistproject.connection.ConnectionFactory; | |
import br.edu.ifpr.persistproject.exception.DatabaseIntegrityException; | |
import br.edu.ifpr.persistproject.model.Seller; | |
import java.sql.*; | |
import java.text.SimpleDateFormat; | |
public class SellerRepository { | |
private Connection conn; | |
private SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); | |
public SellerRepository(){ | |
ConnectionFactory connectionFactory = new ConnectionFactory(); | |
conn = connectionFactory.getConnection(); | |
} | |
public void delete(){ | |
PreparedStatement statement = null; | |
try { | |
statement = conn.prepareStatement( | |
"DELETE FROM department " | |
+ "WHERE " | |
+ "Id = ?"); | |
statement.setInt(1, 2); | |
int rowsAffected = statement.executeUpdate(); | |
System.out.println("Done! Rows affected: " + rowsAffected); | |
} | |
catch (SQLException e) { | |
throw new DatabaseIntegrityException(e.getMessage()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment