This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Not able to connect oracle 11.2 using ODBC6.jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Not able to connect oracle 11.2 using ODBC6.jar" Watch "Not able to connect oracle 11.2 using ODBC6.jar" New topic
Author

Not able to connect oracle 11.2 using ODBC6.jar

vicky Aggarwal
Ranch Hand

Joined: May 15, 2009
Posts: 40
Hi,

I am trying to connect with oracle 11.2 using odbc6.jar
below is my conenction details.
String JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver";
String JDBC_STRING = "jdbcracle:thin:@//CDB:1521/cdb"; // CDB is hostname
String USER_NAME = "USER";
String PASSWD = "pass;
Class.forName (JDBC_DRIVER);
conn = DriverManager.getConnection (JDBC_STRING, USER_NAME, PASSWD);

And i am facing below exeption
java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:458)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:546)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:236)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at oracle.ConnectJDBCOracle11g.main(ConnectJDBCOracle11g.java:25)
Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:392)
at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:434)
at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:687)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:247)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1102)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:320)
... 7 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:150)
at oracle.net.nt.ConnOption.connect(ConnOption.java:133)
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:370)
... 12 more



i am able to connect using sqlplus command
sqlplus USER/pass@//hostname/cdb

I am not able to connect using ip of system in space of hostname.

Any help is greatly appreciated.



Patryk Sosinski
Greenhorn

Joined: Sep 10, 2011
Posts: 18
Are You sure OS can resolve CDB hostname? In console type "ping cdb" to check if your system knows what ip is assigned to cdb. If system cannot resolve cdb name, you have to insert proper record in /etc/hosts file. Also try tnsping cdb.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

Patryk Sosinski wrote:... In console type "ping cdb" to check if your system knows what ip is assigned to cdb...

Good advise.

Patryk Sosinski wrote:...Also try tnsping cdb.

Vicky is using the thin driver. That doesn't use TNS.


OCUP UML fundamental and ITIL foundation
youtube channel
Patryk Sosinski
Greenhorn

Joined: Sep 10, 2011
Posts: 18
Jan Cumps wrote:
Vicky is using the thin driver. That doesn't use TNS.


True, but connection to sqlplus use TNS (i think), so tnsping maybe give some direction what is wrong (maybe different ip is assigned in TNS and different in etc/hosts)

vicky Aggarwal
Ranch Hand

Joined: May 15, 2009
Posts: 40
Patryk Sosinski wrote:... In console type "ping cdb" to check if your system knows what ip is assigned to cdb...


Yes my system can ping that.
But your advice help me to sort my problem.
my system was not able to telnet on 1521 port.

Thanks a lot


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not able to connect oracle 11.2 using ODBC6.jar
 
Similar Threads
JDBC connection issue with RAC database
SQLException : The Network Adapter could not establish connection
connection of JDBC with oracle 9i database
Network adapter connection error
Spring - Connection Problem in some Unit Tests