Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jeffersonchaves/75c0bcd9031014c137c701e645afedb8 to your computer and use it in GitHub Desktop.
Save jeffersonchaves/75c0bcd9031014c137c701e645afedb8 to your computer and use it in GitHub Desktop.
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