you can make connection by jdbc like this
Statement stmt = null;
Connection conn = null;
conn = DriverManager.getConnection
Statement stmt1 =conn.createStatement();
And after this you can add your query and you can use your result according to your need.