Oracle JDBC Connection Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Debabrata Jana
    New Member
    • Mar 2007
    • 8

    #1

    Oracle JDBC Connection Problem

    Please go through the JAVA code below:
    Code:
    class Main{
    public Connection getConnection(){
            Connection l_con = null;
            try {
                String hostname = "172.10.23.1:1527";	//Host IP:port No
                String dbsid = "TESTSID";			//SID Name or Service Name
                String username = "TESTUSER";	//Database user
                String password = "password";		//User password
                String connectingString = "jdbc:oracle:thin:@" + hostname + ":" + dbsid; 
    
                DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
                l_con = DriverManager.getConnection(connectingString,username,password);
    
            } catch (SQLException ex) {
                Logger.getLogger(SQLUtil.class.getName()).log(Level.SEVERE, null, ex);
            }
            return l_con;
        }
    
    
                public static void main(String s[]){
                Main main= new Main();
               Connection l_con = sqlutil.getConnection();              
    }
    
    }
    When I run the following code we found some error like that:

    <ERROR>
    java.sql.SQLExc eption: 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:152 7:TESTSID
    </ERROR>


    Please give me the solution. Thank you.
    Last edited by JosAH; Feb 23 '09, 09:29 AM. Reason: fixed the [code] ... [/code] tags
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by Debabrata Jana
    <ERROR>
    java.sql.SQLExc eption: 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:152 7:TESTSID
    </ERROR>
    The error message says it all: it can't find the TESTSID service/database. Check the spelling, access rights etc.

    kind regards,

    Jos

    Comment

    Working...