Organizational Research By

Surprising Reserch Topic

what jdbc jar to use with oracle 11g jdk 1 6 and how to connect to the db itse


what jdbc jar to use with oracle 11g jdk 1 6 and how to connect to the db itse  using -'oracle,jdbc,oracle11g'

I'm writing a database accessor in Java. The database is in Oracle 11g, of which I am absolutely not familiar, and I have JDK 1.6.


Will ojdbc4.jar do for my program? We're not allowed to connect to the Internet in the office and I can't download ojdbc6.jar, which I've read is more compatible with my setup.
What strings should I put in the Class.forName(String driver) and DriverManager.getConnection(String connectionURL)? I don't know the driver string and the connection URL since they (naturally) look very different from the ones for MS SQL Server.

    

asked Sep 9, 2015 by KirDowns
0 votes
10 views



Related Hot Questions

2 Answers

0 votes

The offical JAR file in combination with JDK 1.6 is ojdbc6.jar. But ojdbc4.jar should work for most applications.

Typicall connection strings are:

jdbc:oracle:thin:user/xxxx@server:port:SID
jdbc:oracle:thin:user/xxxx@//server:port/XE
jdbc:oracle:thin:user/xxxx@:SID
answered Sep 9, 2015 by TemMuramats
0 votes
  1. Oracle bundle the Jar with the Oracle client or server installation and can be found in $ORACLE_HOME/jdbc/lib/ojdbc6.jar. I always use that one.

  2. The Driver classname is oracle.jdbc.OracleDriver and the URL is jdbc:oracle:thin:@//[HOST][:PORT]/SERVICE.

Here's an example (taken from here):

import java.sql.*;
class Conn {
  public static void main (String[] args) throws Exception
  {
   Class.forName ("oracle.jdbc.OracleDriver");

   Connection conn = DriverManager.getConnection
     ("jdbc:oracle:thin:@//localhost:1521/orcl", "scott", "tiger");
                        // @//machineName:port/SID,   userid,  password
   try {
     Statement stmt = conn.createStatement();
     try {
       ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
       try {
         while (rset.next())
           System.out.println (rset.getString(1));   // Print col 1
       } 
       finally {
          try { rset.close(); } catch (Exception ignore) {}
       }
     } 
     finally {
       try { stmt.close(); } catch (Exception ignore) {}
     }
   } 
   finally {
     try { conn.close(); } catch (Exception ignore) {}
   }
  }
}
answered Sep 9, 2015 by Zac1523

...