Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: how to achieve thin driver Connection to oracle XE database?

  1. #1
    Member
    Join Date
    Mar 2011
    Posts
    84
    My Mood
    Daring
    Thanks
    17
    Thanked 1 Time in 1 Post

    Question how to achieve thin driver Connection to oracle XE database?

    I have been known that there are many ways to connect to any database but I came into problems while trying to connect to Oracle XE database.

    Database is freshly installed on local machine. Connection succeeds when connected via SQL+. Making Java web app access it is what creating trouble here. please look at that code ( I know not formally written and Sorry for that but understoodable.
    String username = request.getParameter("username");
    		String password = request.getParameter("password");
     
    		PrintWriter out = response.getWriter();
    		try {
    			Class.forName("oracle.jdbc.driver.OracleDriver");
    		int pass = Integer.parseInt(password);
            String serverName = null;
            //String sid = null;
            String portNumber = "1521";
            String dusername = "system";
            String dpassword = "honour";
     
            serverName = "localhost";
            String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber +":xe,'"+dusername+"','"+dpassword+"'";
            Connection conn = null;
     
            conn = DriverManager.getConnection(url);

    last line is where issue happens. Also please look at server console below :
    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

    at oracle.jdbc.driver.T4CConnection.logon(T4CConnecti on.java:489)
    at oracle.jdbc.driver.PhysicalConnection.<init>(Physi calConnection.java:553)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnect ion.java:254)
    at oracle.jdbc.driver.T4CDriverExtension.getConnectio n(T4CDriverExtension.java:32)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriv er.java:528)
    at java.sql.DriverManager.getConnection(DriverManager .java:571)
    at java.sql.DriverManager.getConnection(DriverManager .java:233)
    at logger.Logger.processRequest(Logger.java:49)
    at logger.Logger.doPost(Logger.java:27)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:647)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:728)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
    at org.apache.tomcat.websocket.server.WsFilter.doFilt er(WsFilter.java:51)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBas e.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(A ccessLogValve.java:953)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.p rocess(AbstractHttp11Processor.java:1041)
    at org.apache.coyote.AbstractProtocol$AbstractConnect ionHandler.process(AbstractProtocol.java:603)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProce ssor.run(JIoEndpoint.java:312)
    at java.util.concurrent.ThreadPoolExecutor.runWorker( ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
    Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
    ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

    at oracle.net.ns.NSProtocol.connect(NSProtocol.java:3 99)
    at oracle.jdbc.driver.T4CConnection.connect(T4CConnec tion.java:1140)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnecti on.java:340)
    ... 29 more
    I identified the issue as the error states but I don't know how to resolve it. I'll be glad if you help me out. please tell me what changes I need to make in my connection string so as to make it work.
    Hoping to have replies from Gurus.
    Thank you


  2. #2
    Member
    Join Date
    Sep 2013
    Posts
    68
    My Mood
    Confused
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default Re: how to achieve thin driver Connection to oracle XE database?

    Check all the oracle services should start in your machine.

Similar Threads

  1. locked <0x28f8d398> (a oracle.jdbc.driver.T4CConnection)
    By ravi_59ece in forum What's Wrong With My Code?
    Replies: 0
    Last Post: December 18th, 2013, 02:27 AM
  2. Replies: 0
    Last Post: December 18th, 2013, 02:24 AM
  3. Oracle connection
    By webluca in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 16th, 2013, 08:36 AM
  4. Replies: 1
    Last Post: December 21st, 2012, 10:35 AM
  5. [SOLVED] JComboBox with database Oracle.
    By Thabby in forum Java Theory & Questions
    Replies: 2
    Last Post: December 12th, 2012, 04:22 PM

Tags for this Thread