Forums Register Login

Connection to database Exception

+Pie Number of slices to send: Send
Hi

I am trying to connect to oracle database in my application however i get the following exception
Inside the second try block
java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:254)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:386)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:413)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:164)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:34)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:752)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at Dbconnection.main(Dbconnection.java:17)

and my code is as follows



I am unable to follow where the error is occuring
+Pie Number of slices to send: Send
String url="jdbc:oracle:thin:@localhost:1521:scott";

That scott above should be the database name, not the user id.
+Pie Number of slices to send: Send
i changed the url and username and password and still the exception stays.

Changes are:-
+Pie Number of slices to send: Send
From the sql plus window, enter the following in the user id field test/test@dbname. Does it connect?
+Pie Number of slices to send: Send
swastik,

I am unable to connect to my database using the username and password
+Pie Number of slices to send: Send
user id:test
password:test
host string:dbname

does this work?
+Pie Number of slices to send: Send
A small modification, in the connection string it's not exactly the dbname, rather it's the service id.
+Pie Number of slices to send: Send
what does a service id mean
in tnsnames.ora ?
I cant understand
+Pie Number of slices to send: Send
but if i only give the SID how will the database name be found
+Pie Number of slices to send: Send
So far as I know using a sid a particular oracle instance is identified, i.e. the address where it's located, protocol being used etc.
+Pie Number of slices to send: Send
sid itself is mapped to a particular database instance.
+Pie Number of slices to send: Send
If you go to administrative tools-services, you should get the names of oracle services running.
+Pie Number of slices to send: Send
my database is MyDatabase .
After the given url used for connecting to the database ,
ie the url with SID how will a particular schema be called ?
+Pie Number of slices to send: Send
Each particular sid is mapped to a particular db instance, and accordingly you have to configure listeners in tnsnames.ora. For e.g. if you have a db instance running as orcl, you may configure a sid in tnsnames.ora as orcl, and if you have another db instance running as mydatabase, you need to configure a sid for this too.
+Pie Number of slices to send: Send
 

Swastik Dey wrote:Each particular sid is mapped to a particular db instance, and accordingly you have to configure listeners in tnsnames.ora. For e.g. if you have a db instance running as orcl, you may configure a sid in tnsnames.ora as orcl, and if you have another db instance running as mydatabase, you need to configure a sid for this too.

Are you talking about the server side, or the client side?
+Pie Number of slices to send: Send
I haven't worked much with oracle. But as far as my knowledge goes tnsnames.ora is configured at client side. Correct me if I am wrong.
+Pie Number of slices to send: Send
 

Swastik Dey wrote:I haven't worked much with oracle. But as far as my knowledge goes tnsnames.ora is configured at client side. Correct me if I am wrong.

If you use the thin client, no tnsnames configuration on client side is required.
+Pie Number of slices to send: Send
Thanks
In that case what comes in place of question mark?

jdbc:oracle:thin:@localhost:1521:?

+Pie Number of slices to send: Send
from http://blogs.oracle.com/theshortenspot/2009/04/advanced_oracle_jdbc_connectio.html

jdbc:oracle:thin:@[hostname]:[dbport]:[database]

where
[hostname] - Database hostname
[dbport] - Database Listener portname
[database] - Database Name

[edit: disabled smilies]
It was the best of times. It was the worst of times. It was a tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 8137 times.
Similar Threads
java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
New to JDBC - problems
connect oracle from java application
Io exception: There is no process to read data written to a pipe.
Anyone please tell the reason for the following exception & how to solve it
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 23:21:46.