which has ... nothing at all to do with being a servlet or not. you are simply calling a select statement.
again: what you need to know for this is basic jdbc, jpa, hibernate, or any other persistence framework.
In the example linked to by mutago, it's basic jdbc. A suggestion, don't study from RoseIndia. even though the site has been around for quite a while, it has some very huge flaws:
the code isn't documented, and there are no comments explaining what is happening, so you can copy paste, but actually understanding the how, what and why is not really provided.
information that is given there, is not necessarily correct, and the code snippets aren't actualy beeing kept up to date.
it's better to check the official tutorials provided by Oracle. they're kept up to date, and corrected when an error is found.