This is not specific to DB2.
What you really need to do is to read the SQL adapter training module, and learn how to send data to and retrieve data from - a database. Then you need to review the sample project provided in the same URL above.
You can also take a look at the following (after you read the training module). The concept is the same in nature, just for DB2...: