Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2004
    Location
    Kuwait
    Posts
    2

    Unhappy Unanswered: The Network Adapter could not establish the connection

    I'm a beginner user of Oracle 9i database Realease 2 (9.2.0.1.0.).
    I need to run a java code that connects to a database using JDBC. The problem is that I have this error that made me crazy. I really ran out of ideas, I wish that any one would help me.
    I can connect to the database successfully using sql+. I have checked that the listener is functioning correctly using Oracle Enterprise Manager Console.
    I'm using Windows XP Professional and when I run my code I get the following:

    C:\Code>java -classpath classes111.jar;. pinev1_1qpt 425 10 res 1>Restaurant_425.txt
    java.sql.SQLException: ????غ?? ع??ط??/ع?????: The Network Adapter could not establish the connection
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java)
    at oracle.jdbc.driver.OracleConnection.<init>(OracleC onnection.java)
    at oracle.jdbc.driver.OracleDriver.getConnectionInsta nce(OracleDriver.java)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriv er.java)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at pinev1_1qpt.<init>(pinev1_1qpt.java:70)
    at pinev1_1qpt.main(pinev1_1qpt.java:26)


    Important Parts of my Code
    __________________________
    import java.util.*;
    import java.sql.*;
    import java.io.*;

    public pinev1_1qpt()
    {
    //Create the JDBC connection which is used for executing queries throughout the rest of the program
    try
    {
    System.out.print("Looking for Oracle's JDBC driver...");
    DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
    System.out.println("Loaded.");

    String URL = "jdbc:oracle:thin:@altaf-sab:1521:infolabm";
    //String URL = "jdbc:oracle:thin:@127.0.0.1:1521:infolabm";
    String userName = "system";
    String password = "syspassword";

    System.out.print("Connecting to DB...");
    MainConnection = DriverManager.getConnection(URL, userName, password);
    System.out.println("Connected!");

    QueryStatement1 = MainConnection.createStatement();
    QueryStatement2 = MainConnection.createStatement();
    }
    catch( Exception e )
    {
    System.out.println( "Error connecting to DB: "+ e.toString() );
    e.printStackTrace();
    System.exit(-1);
    }
    System.out.println();
    }

    Environment Variables
    _____________________

    CLASSPATH C:\Code\classes111.jar

    JAVA_HOME C:\jdk1.3.1

    Path C:\oracle\ora92\bin;
    C:\Program Files\Oracle\jre\1.3.1\bin;
    C:\Program Files\Oracle\jre\1.1.8\bin;
    %SystemRoot%\system32;
    %SystemRoot%;
    %SystemRoot%\System32\Wbem;
    C:\jdk1.3.1\bin

    C:\WINDOWS\system32\drivers\etc\hosts
    _____________________________________
    127.0.0.1 altaf-sab

    C:\oracle\ora92\network\admin\tnsnames.ora
    __________________________________________
    # TNSNAMES.ORA Network Configuration File: C:\oracle\ora92\network\admin\tnsnames.ora
    # Generated by Oracle configuration tools.

    OEMREP =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = altaf-sab)(PORT = 1521))
    )
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = OEMREP)
    )
    )

    INST1_HTTP =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = altaf-sab)(PORT = 1521))
    )
    (CONNECT_DATA =
    (SERVER = SHARED)
    (SERVICE_NAME = MODOSE)
    (PRESENTATION = http://HRService)
    )
    )

    EXTPROC_CONNECTION_DATA =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
    (CONNECT_DATA =
    (SID = PLSExtProc)
    (PRESENTATION = RO)
    )
    )

    INFOLABM =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = altaf-sab)(PORT = 1521))
    )
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = infolabm.world)
    )
    )


    C:\oracle\ora92\network\admin\listener.ora
    __________________________________________
    # LISTENER.ORA Network Configuration File: C:\oracle\ora92\network\admin\listener.ora
    # Generated by Oracle configuration tools.

    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = altaf-sab)(PORT = 1521))
    )
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
    )
    )

    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = C:\oracle\ora92)
    (PROGRAM = extproc)
    )
    (SID_DESC =
    (GLOBAL_DBNAME = infolabm.world)
    (ORACLE_HOME = C:\oracle\ora92)
    (SID_NAME = infolabm)
    )
    (SID_DESC =
    (GLOBAL_DBNAME = OEMREP)
    (ORACLE_HOME = C:\oracle\ora92)
    (SID_NAME = OEMREP)
    )
    )

  2. #2
    Join Date
    Oct 2004
    Location
    Kuwait
    Posts
    2
    I found the solution to my problem
    I shall add classes12.jar to my classpath, which is compatible with the JDK that I'm using (1.3).

    Thanks for reading my post and trying to solve it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •