Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jeffersonchaves/3ed2531d9e31c7269ffec98692c77881 to your computer and use it in GitHub Desktop.
Save jeffersonchaves/3ed2531d9e31c7269ffec98692c77881 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.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 update(){
PreparedStatement statement = null;
try {
statement = conn.prepareStatement(
"UPDATE seller SET BaseSalary = BaseSalary + ? WHERE DepartmentId = ?");
statement.setDouble(1, 200.0);
statement.setInt(2, 2);
int rowsAffected = statement.executeUpdate();
System.out.println("Done! Rows affected: " + rowsAffected);
}
catch (SQLException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment