I have a code snippet to connect to Oracle 11g. Below code works in XP machine (using IBM RAD 7.0 jdk 1.5), but when I use the same code in Win7 machine (IBM RAD 8.0 jdk 1.6). I am getting the exception below. Could someone help me. I am using ojdbc14.jar on both the scenarios.
java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
But I am able to ping the host..Should that be fine?
not necessarily. ping uses ICMP. JDBC uses TCP.
You need to enable TCP traffic to your server IP, port 1521 (or whatever your Listener there listens on), and, for the opened connection, back from that server (whatever port) to your Client.
Or enable it for application (java executable).
open Control Panel, Windows Firewall, Advanced Settings.
Select Inbound Rules.
Add New Rule: Custom, All programs, proto TCP, All Local Ports, Any Local IP, Remote IP <Oracle Server Host IP>, Allow Connection.
You can test connectivity via telnet to the Oracle port: "telnet dev64-scan 1521". If that opens a connection, your firewall is not in the way.
You can test your tnsnames configuration with sqlplus. If sqlplus can connect you to your instance on dev64-scan, your tnsnames and listener are correct.
If telnet and sqlplus are good and you still can't connect via jdbc, you might try a jdbc-based utility such as the SQL Explorer plugin for Eclipse, or an equivalent. If you can enter your connect information and reach the db that way, you know your jdbc drivers and configuration are correct.