0

Here is the code which i am trying- ORACLE driver is loaded successfully but getting in get connection that statement-

public class OracelConn {
   public static void main(String[] args) throws Exception {
      try {
         try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
         } catch (ClassNotFoundException e) {
            System.out.println("Please include Classpath  Where your ORACLE Driver is located");
            e.printStackTrace();
            return;
         }
         System.out.println("ORACLE driver is loaded successfully");
         Connectioncon=DriverManager.getConnection( "jdbc:oracle:thin:or0132p.exg.com:1521:OP0132.exg.com", "wsteam", "wsteam");

         Statement stmt = con.createStatement();
         ResultSet rs = stmt.executeQuery("select TC_ORDER_ID from orders where tc_order_id='0296906379'");
         while (rs.next())
            System.out.println(rs.getString("TC_ORDER_ID"));

         con.close();
         } catch (Exception e) {
             System.out.println(e);
         }
      }
   }
3
  • Basically getting error on- Connectioncon=DriverManager.getConnection("jdbc:oracle:thin:or0132p.exg.com:1521:OP0132.exg.com","wsteam", "wsteam"); and the error is--> java.sql.SQLException: Io exception: The Network Adapter could not establish the connection Commented Dec 2, 2018 at 12:45
  • seems I reached to this question late! Commented Dec 3, 2018 at 0:26
  • @Mehdi Thanks for looking into it Commented Dec 3, 2018 at 12:17

1 Answer 1

1

There seems to be an issue with your URL format. Below are supported formats:

If you have an SID, use this (older) format:

jdbc:oracle:thin:@[HOST][:PORT]:SID

If you have an Oracle service name, use this (newer) format:

jdbc:oracle:thin:@//[HOST][:PORT]/SERVICE

Source: orafaq

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @Sukphal... it worked here only the newer format is working as i have the service name...thanks for this--> ("jdbc:oracle:thin:@or0132p.abc.com:1521/OP0132.abc.com", "user", "pwd" )................. i was using the SID one not the Service one as i have the service name

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.