Commit a4b7ca3d by Patryk Czarnik

Jeszcze prostszy update

parent d5c93f8f
......@@ -7,16 +7,14 @@ import java.sql.SQLException;
public class P05_ProstyUpdate {
public static void podwyzka(int zmiana, int min, int max) {
String sql = "UPDATE employees SET salary = salary + ? "
+ "WHERE salary BETWEEN ? AND ?" ;
public static void main(String[] args) {
String sql = "UPDATE employees SET salary = salary + ? WHERE job_id = ?" ;
try(Connection c = DriverManager.getConnection(Ustawienia.URL, Ustawienia.USER, Ustawienia.PASSWD);
PreparedStatement stmt = c.prepareStatement(sql)) {
stmt.setInt(1, zmiana);
stmt.setInt(2, min);
stmt.setInt(3, max);
stmt.setInt(1, 333);
stmt.setString(2, "IT_PROG");
int ile = stmt.executeUpdate(); // uwaga, tego używamy także dla insert czy delete
// Dokładnie mówiąc: ilu wierszy dotyczyło zapytanie.
......@@ -25,8 +23,4 @@ public class P05_ProstyUpdate {
e.printStackTrace();
}
}
public static void main(String[] args) {
podwyzka(333, 10000, 20000);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment