Click here to Skip to main content
15,912,977 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hi friends i am getting this error of
Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
alpdfdb.alc.aff.com:1521:comwhen
i try to connect to data base.actually i can connect to database in sql developer but when i try it from java code it give me this error.
my code is
Java
Connection con;
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@alpdfdb.alc.aff.com:1521:com","abc","xyz");
System.out.println("con successed");


I am using oracle sql developer v 2.1

please help me.
Posted
Updated 31-Aug-12 8:14am
v3

Learn more about Oracle SQl Developer[^]

And as I assume you are using Netbeans for Java development -
this one desribes pretty well what to do:

Connecting to Oracle Database from NetBeans IDE[^]
 
Share this answer
 
Have you tried with servicename instead of sid http://docs.oracle.com/cd/B28359_01/java.111/b31224/urls.htm#BEIDHCBA[^]? According to this one (http://www.herongyang.com/JDBC/Oracle-JDBC-Driver-Connection-URL.html[^]) your url is correct, but it looks, like you are using a deprecated driver, try oracle.jdbc.OracleDriver instead of oracle.jdbc.driver.OracleDriver.
 
Share this answer
 
Thanks friends I got the answer
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@ffgt.com:1521/fgB.DB.DT.COM","ABC","xyz");

BY PUTING / BETWEEN PORT NO & SERVICE NAME INSTED OF :
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900