title: remotely connecting oracle database with java
body: <p>I'm trying to figure out how to connect to oracle database remotely, in order to fetch information/data from it. I don't know the steps on how to go about it. I would also like to use datasource to connect with the oracle DB. I'm completely new to this, and if its not too much to ask can I get step by steps on how to do this. I'm using liberty server.</p>
  
  <p>All I have done is read through the internet for something that answers my query but i just cant seem to find what I'm looking for. Below is what I have and I'm trying to see how to achieve my goal from what I have. </p>
  
  <p>In this scenario I want to use datasource and connect remotely with oracle DB.</p>
  
  <pre class="lang-java prettyprint-override"><code>package com.dBconnect;
  
  import java.sql.Connection;
  import java.sql.SQLException;
  import javax.naming.InitialContext;
  import javax.naming.NamingException;
  import javax.sql.DataSource;
  
  public class DatabaseUtility {
  
      private static DataSource dataSource;
      static Connection conn;
  
      public static void main(String ars[]) {
          try {
              conn = dataSource.getConnection();
              System.out.println("connection established");
  
          } catch (Exception e) {
              e.printStackTrace();
  
          } finally {
              try {
                  conn.close();
              } catch (SQLException e) {
                  e.printStackTrace();
              }
          }
      }
  }
  </code></pre>