From a servlet, you can use code similar to the Java database connection sample for querying the database.
There are a number of ways to connect to Oracle from a variety of other languages. Some examples are provided for you to start with:
Login in formation of using Tora with an example how to create table: