Here is the best way to do this:
String sql = "INSERT INTO studenten (id, naam, adres, postcode, plaats, geboren)"
+ " VALUES (?, ?, ?, ?, ?, ?)"
try {
connection = database.getConnection();
statement = connection.prepareStatement(sql);
statement.setLong(1,your_id_value);
statement.setString(2,contact.getNaam());
statement.setString(3,contact.getAdres());
statement.setString(5,contact.getPlaats());
statement.setString(4,contact.getPostcode());
statement.setDate(6,getGeboren());
statement.executeUpdate();
statement.close();
} catch(java.sql.Exception sql_exception ){
e.printStackTrace();
}
source
share