import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; import java.time.LocalDate; public class App { public static void updateEmployee(Employee emp) { Connection conn = null; try { String url = "jdbc:mariadb://localhost:3306/surubt"; conn = DriverManager.getConnection(url, "surubt", "titok"); String sql = "update employees set " + "name=?, city=?, salary=?, birth=? "+ "where id=?"; PreparedStatement pstmt = conn.prepareStatement(sql); pstmt.setString(1, emp.name); pstmt.setString(2, emp.city); pstmt.setDouble(3, emp.salary); pstmt.setDate(4, java.sql.Date.valueOf(emp.birth)); pstmt.setInt(5, emp.id); pstmt.execute(); System.out.println("A frissítés sikeres."); }catch(SQLException ex) { System.err.println("Hiba! Az SQL művelet sikertelen!"); System.err.println(ex.getMessage()); } } public static void main(String[] args) throws Exception { System.out.println("Frissítés..."); Employee emp = new Employee( 6, "Becses Géza", "Miskolc", 391, LocalDate.parse("2000-03-22") ); updateEmployee(emp); } }