This is more of a
JDBC question.
You will identify the oracle driver and database.
You will execute the query using sql and JDBC apis provided by JDK and also oracle
java related classes.(you need the oracle related jar files in the path)
There should be some example for this in oracle website or the web site of the app server you are using. This should be useful as a starting point for you.
You can always log or debug your query statement and returned output.
Have fun,
Kishore.