Network Adapter could not establish connection [message #91118] |
Mon, 15 April 2002 19:07 |
Siddhartha Mehta
Messages: 3 Registered: April 2002
|
Junior Member |
|
|
I am trying for a simple connection between Java and Oracle and I have been trying since last couple of days but does not work. I have pasted tnsnames.ora, litener.ora, Test.java and the exception I get. Could anyone please look into and help me if everything looks fine. Thanks for the help.
My hostname: shail
Port: 1521
SID: ORACLE
Thanks Siddhartha
tnsnames.ora
# C:ORACLEORA81NETWORKADMINTNSNAMES.ORA Configuration File:c:OracleOra81networkadmintnsnames.ora
# Generated by Oracle Net8 Assistant
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
ORACLE_SHAIL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = shail)(PORT = 1521))
)
(CONNECT_DATA =
(SID = ORACLE)(SERVER = DEDICATED)
)
)
listener.ora
# C:ORACLEORA81NETWORKADMINLISTENER.ORA Configuration File:c:OracleOra81networkadminlistener.ora
# Generated by Oracle Net8 Assistant
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = shail)(PORT = 1521))
)
)
(DESCRIPTION =
(PROTOCOL_STACK =
(PRESENTATION = GIOP)
(SESSION = RAW)
)
(ADDRESS = (PROTOCOL = TCP)(HOST = shail)(PORT = 2481))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = c:OracleOra81)
(PROGRAM = extproc)
)
)
LISTENER =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = ORACLE))
(ADDRESS = (PROTOCOL = TCP)(HOST = shail)(PORT = 1521))
)
sid_list_LISTENER =
(sid_list =
(sid_desc =
(sid_name = ORACLE)
(ORACLE_HOME = c:OracleOra81)
)
)
Test.java
import java.sql.*;
class Test {
public static void main (String args [[]]) throws SQLException {
// Load Oracle driver
try {
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
System.out.println("Before Connection");
// Connect to the local database
Connection conn =
DriverManager.getConnection ("jdbc:oracle:thin:@shail:1521:ORACLE",
"scott", "tiger");
System.out.println("After Connection");
// Query the date
Statement stmt = conn.createStatement ();
ResultSet rset = stmt.executeQuery ("select sysdate from dual");
// Print the name out
while (rset.next ())
System.out.println (rset.getString (1));
}
catch(Exception ioe)
{
ioe.printStackTrace();
}
}
}
Error Message
Before Connection
java.sql.SQLException: The Network Adapter could not establish the connection
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:407)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:152)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:214)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:193)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Test.main(Test.java:13)
|
|
|
|
|