title: What is the difference between OCI and THIN driver connection with data source connection between java and oracle XE?
body: <p>I'm writing the below codes for connection between the java and Oracle 10g XE using 3 way(OCI, THIN and data source), the code is running successfully but don't know difference between the THIN and OCI with data source connection.</p>
  
  <p>1-</p>
  
  <pre><code>public static void main (String args[]) throws SQLException
   {
    OracleDataSource ods = new OracleDataSource();
    ods.setURL("jdbc:oracle:thin:hr/hr@localhost:1521/XE");
    Connection con = ods.getConnection();
    System.out.println("Connected");
    con.close();
   }
  </code></pre>
  
  <p>2-    </p>
  
  <pre><code>public static void main(String args[])
       {
        try
        {
         // load oracle driver
        Class.forName("oracle.jdbc.driver.OracleDriver");
        // connect using Thin driver
        Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","hr","hr");
        System.out.println("Connected Successfully To Oracle");
        con.close();
        }
        catch(Exception ex)
        {
          ex.printStackTrace();
        }
   }
  </code></pre>
  
  <p>3-</p>
  
  <pre><code>public static void main(String args[])
       {
        try
        {
         // load oracle driver
        Class.forName("oracle.jdbc.driver.OracleDriver");
        // connect using Native-API (OCI) driver
        Connection con = DriverManager.getConnection("jdbc:oracle:oci:@","hr","hr" );
        System.out.println("Connected Successfully To Oracle using OCI driver");
        con.close();
        }
        catch(Exception ex)
        {
          ex.printStackTrace();
        }
   }
  </code></pre>