Here is a very basic sample of connecting to a drillbit via Java and retrieving records.
The code connects to the drillbit using DriverManager and the constructed URL. Then a Statement object is created, which is used to execute the SQL query and returning a Resultset. The while loop, loops over the records in the resultset and prints the value of a column labeled "name". Finally the resultset and connection are closed.