By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,199 Members | 1,474 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,199 IT Pros & Developers. It's quick & easy.

Oracle JDBC Connection Problem

P: 8
Please go through the JAVA code below:
Expand|Select|Wrap|Line Numbers
  1. class Main{
  2. public Connection getConnection(){
  3.         Connection l_con = null;
  4.         try {
  5.             String hostname = "172.10.23.1:1527";    //Host IP:port No
  6.             String dbsid = "TESTSID";            //SID Name or Service Name
  7.             String username = "TESTUSER";    //Database user
  8.             String password = "password";        //User password
  9.             String connectingString = "jdbc:oracle:thin:@" + hostname + ":" + dbsid; 
  10.  
  11.             DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
  12.             l_con = DriverManager.getConnection(connectingString,username,password);
  13.  
  14.         } catch (SQLException ex) {
  15.             Logger.getLogger(SQLUtil.class.getName()).log(Level.SEVERE, null, ex);
  16.         }
  17.         return l_con;
  18.     }
  19.  
  20.  
  21.             public static void main(String s[]){
  22.             Main main= new Main();
  23.            Connection l_con = sqlutil.getConnection();              
  24. }
  25.  
  26. }
  27.  
  28.  
When I run the following code we found some error like that:

<ERROR>
java.sql.SQLException: 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:
172.10.23.1:1527:TESTSID
</ERROR>


Please give me the solution. Thank you.
Feb 23 '09 #1
Share this Question
Share on Google+
1 Reply


Expert 10K+
P: 11,448
@Debabrata Jana
The error message says it all: it can't find the TESTSID service/database. Check the spelling, access rights etc.

kind regards,

Jos
Feb 23 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.