I tried searching in Google, but I could not find any good examples where a username and password are checked with a database for authentication purposes.
In further
If you're using a database that can be accessed with JDBC then you don't need to create a custom authentication-provider. The authentication-provider already allows you to query the database directly. It'll reduce the required code to 9 lines of XML instead of a multitude of classes.
I've answered this here with code samples: Spring Security 3 database authentication with Hibernate