Modifying a database is just as
simple as querying a database. However, instead of using
executeQuery(), you use executeUpdate() and you don't have
to worry about a result set. Consider the following example:
Connection jdbcConnection =
Statement sqlStatement = jdbcConnection.createStatement();
// We have seen all of the above before.
// No surprises so far. in the next line, we
// will simply create a string of SQL.
String sql = "INSERT INTO CUSTOMERS +
" (CustomerID, Firstname, LastName, Email)" +
" VALUES (004, 'Selena', 'Sol' " +
// Now submit the SQL....
As you can see, there is not much to it.
Add, modify and delete are all handled by the
executeUpdate() method. You compose the SQL and send it
through JDBC in one simple call.