Tag Archives: Oracle

JDBC: Connection With Oracle Database

For connecting with the Oracle database from JAVA application, you need to follow 5 steps to perform database connectivity. Below are connection information specific to oracle database:

  1. Driver class: The driver class for the oracle database is oracle.jdbc.driver.OracleDriver.
  2. Connection URL: The connection URL for the oracle database is jdbc:oracle:thin:@localhost:1521:FacingIssuesOnITDB here jdbc is the API, oracle is the database, localhost is the server name on which oracle is running, we may also use IP address, 1521 is the port number and FacingIssuesOnITDB is the database name. We may use any database, in such case, you need to replace the FacingIssuesOnITDB with your database name.
  3. Username: The default username for the oracle database is root.
  4. Password: Password is given by the user at the time of installing the oracle database. In this example, we are going to use root as the password.
import java.sql.*;
class OracleConnection{
public static void main(String args[]){
//Step 1: Register the driver class
//Step 2: Create connection with database
   Connection con=DriverManager.getConnection(
//here FacingIssuesOnITDB is database name, root is username and password
//Step 3: Create statement
 Statement stmt=con.createStatement();
//Step 4: Execute query
 ResultSet rs=stmt.executeQuery("select * from emp");   

  System.out.println(rs.getInt(1)+"  "+rs.getString(2)+"  "+rs.getString(3));
//Step 5: close connection
catch(ClassNotFoundException e){
catch(SQLException e){

Here you learn about steps to connect database with application and specific configuration information for Oracle.

See also :

Learn More on JDBC

Follow below links to learn more on JDBC and solving JDBC related issues :

How to add 3rd Party/Custom/External Jars to Maven Project?

In below steps will show about to add 3rd party/custom/external Jars in local repository for use in our project builds because these jars doesn’t exist in Maven public repository and required to build project.


To add these jars we can use below command to load in local repository (.m2/repository)

mvn install:install-file -Dfile= -DgroupId=
-DartifactId= -Dversion= -Dpackaging=

Example : Oracle is 3rd party and it’s jars are available in maven public repository. We can use below command to store in maven local repository and make entry in pom.xml to use it.

mvn install:install-file -Dfile=C:\\Workspace\\ojdbc6.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar

pom.xml entry for above oracle jar