Created
May 8, 2023 13:54
-
-
Save jeffersonchaves/3ed2531d9e31c7269ffec98692c77881 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.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