The logical step after querying a database (see the Querying an SQL database recipe) is writing data to it. This recipe shows how a few lines of Groovy and very little boilerplate is needed to do the job of modifying data in a database table.
This recipe also uses the same table structure and the way to start a database server defined in the Creating a database table recipe.
As usual, create a new Groovy script named
modifyDb.groovy. As for the previous recipes, in this case we also need to import the
import static DBUtil.* import groovy.sql.Sql def server = startServer() createSchema()