Font Awesome Icons


Connectivity with Oracle

For connecting java application with the oracle database, you need to follow 5 steps to perform database connectivity:

1)Driver class: The driver class for the oracle database is oracle.jdbc.driver.OracleDriver.

2)Connection URL: The connection URL for the oracle10G database is jdbc:oracle:thin:@localhost:1521:xe where jdbc is the API, oracle is the database, thin is the driver, localhost is the server name on which oracle is running, we may also use IP address, 1521 is the port number and XE is the Oracle service name. You may get all these informations from the tnsnames.ora file.

3)Username: The default username for the oracle database is system.

4)Password: Password is given by the user at the time of installing the oracle database.

Example to Connect Java Application with Oracle database:

import java.sql.*; 

class OracleCon

public static void main(String args[])


//step1 load the driver class 



//step2 create  the connection object 

Connection con=DriverManager.getConnection( 


  //step3 create the statement object 

Statement stmt=con.createStatement();


//step4 execute query 

ResultSet rs=stmt.executeQuery(“select * from emp”); 


System.out.println(rs.getInt(1)+”  “+rs.getString(2)+”  “+rs.getString(3)); 


//step5 close the connection object 



}catch(Exception e)





Hi, Welcome to etechvidya