If a Java program needs to establish a connection with a backend Oracle server it can do so by using the functions provided by its SQL class. These functions make use of the Java Database Connectivity (JDBC) drivers provided by Oracle to open connection with the database and interact with it. Oracle provides OCI and THIN type of JDBC drivers for both server and client side, referred to as Type 2 and Type 4 drivers.
Check out this code to make your Java program connect to an Oracle Database instance using JDBC-Thin Type 4 Driver.
Click here to read more.