This is a very broad question. I will take a shot at trying too keep it simple and short.
Here are the steps.
- First create a backing bean that works with your front end face page.
- Create a service class that encapsulates the CRUD tasks.
- Create a database methods class that performs each CRUD task.
This is how the code should flow:
"Your UI face invokes a method in the backing bean->the backing bean invokes service class->service invokes the database methods class. This is commonly referred to as the DAO pattern."
For details on how to connect to a database.
- You can either create a local data source and connect via standard JDBC procedure.
- Or you can create connection pools in your container (JBOSS, WebLogic, etc). Then look up those connection pools in your app via JNDI lookup.
If you are very new to this, then I would recommend to start out with creating a basic database connection using JDBC and running your queries against it. In the long term, you will want to get yourself familiar with connection pool (actually this will give you a better performance too), Spring JDBC framework, ORM support (hibernate, iBatis).
Here is a link to starting a jdbc connection for Microsoft SQL server (example on step1).