import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.Properties; import java.time.LocalDate; public class App { public static void main(String[] args) throws Exception { String url = "jdbc:postgresql://localhost/zoldzrt"; Properties props = new Properties(); props.setProperty("user", "zoldzrt"); props.setProperty("password", "titok"); props.setProperty("ssl", "ture"); try { Connection conn = DriverManager.getConnection(url, props); System.out.println("Ok. A kapcsolódás sikeres."); String sql = "insert into employees" + "(name, city, salary, birth)" + "values" + "(?, ?, ?, ?)"; PreparedStatement ps = conn.prepareStatement(sql); ps.setString(1, "Csintalan Ervin"); ps.setString(2, "Hatvan"); ps.setDouble(3, 396); ps.setDate(4, java.sql.Date.valueOf(LocalDate.parse("1998-04-02"))); ps.execute(); } catch (SQLException e) { System.err.println("Hiba!"); System.err.println(e.getMessage()); } } }