• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.sql.SQLException

 
pratike shahh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to connect to a Oracle Database. From my local machine I am able to use SQL Plus and connect to the Database.

This is code I am using:
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection("jdbcracle:thin:@Database_IP:1521:SID","usr","pwd");
DatabaseMetaData meta = conn.getMetaData();
System.out.println("JDBC driver version is " + meta.getDriverVersion());

Where SID value is what I obtained from select instance_name from v$instance;
and Database_IP is the IP address of the server hosting Oracle.

However I get the exception:
java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:439)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at ReadOracle.main(ReadOracle.java:8)

Please help me solve this issue,
Thanks,
Pratik
 
Siva Masilamani
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
make sure listener is up and running.
 
pratike shahh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.
I dont have access to the server, is this something I can do via SQL Plus..
Or how can I check that.

Sorry but I am fairly new to all this..

Regards,
Pratik
 
Siva Masilamani
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This link may help you

webpage

Especially look at this response parthas_k@yahoo.com in that link
 
pratike shahh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply,
I've already tried suggestions in that link, but still the same error.

Any more suggestions...
 
Siva Masilamani
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pratike shahh wrote:Thanks for the reply,
I've already tried suggestions in that link, but still the same error.

Any more suggestions...


Did you try everything stated in the link?

Did you check the listener is running?

Did you see the tnsnames.ora file for the valid information?
 
srinivas srinivasmeenavalli
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are you able to ping server IP
open command prompt and try to run c:/ping Database_IP
 
srinivas srinivasmeenavalli
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have one more question . What kind of program it is ?
is it being called from a applet or stand alone ?
 
pratike shahh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a test program which I am trying to run from my local machine.
Eventually this will be a middleware program for one of our interfaces.
 
pratike shahh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay this is what I tried and it seems to work:
1. Created s DSN entry on my machine
2. And then used:
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
Connection con=DriverManager.getConnection(“jdbcdbcSN name”,”usr”,”pwd”);

And this seems to work, I tried a test query and it seems to work..

Is this is also a right way to do so..
Eventually this program will run on one of our servers as an Interfac/middleware program..

Thanks,
Pratik
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic