• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not able to connect oracle 11.2 using ODBC6.jar

 
vicky Aggarwal
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2584
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Patryk Sosinski
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
Anil Kesarwani
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your JDBC String value should be "jdbcracle:thin:@//CDB:1521:cdb" in place of "jdbcracle:thin:@//CDB:1521/cdb"
 
Jan Cumps
Bartender
Posts: 2584
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for joining the Ranch, Anil!

I believe that the original poster used the right connection. What you see there is that the forum translated colon+o into a smiley.



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic