1 2 Previous Next 22 Replies Latest reply on Jun 7, 2011 3:04 PM by 867187

    Oracle 10g JDBC connection refused error

    201187

      Hi!!

      I am working in oracle 10g and set classpath for jdbc driver file which is zip file
      and have the following error.
      I installed oracle 9i in the same machine but my program can access the oracle 9i database using oracle jdbc thin driver.
      Anyone tell me what's wrong ?
      ===========================================================

      java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153092352)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:334)
      at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:418)
      at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:521)
      at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:325)
      at java.sql.DriverManager.getConnection(DriverManager.java:512)
      at java.sql.DriverManager.getConnection(DriverManager.java:171)
      at Migrate2.main(Migrate2.java:47)

        • 1. Re: Oracle 10g JDBC connection refused error
          Avi Abrami
          shine99,
          Here is the description for the error code you are getting:
          aabrami 1> oerr ora 12505
          12505, 00000, "TNS:listener does not currently know of SID given in connect descriptor"
          // *Cause:  The listener received a request to establish a connection to a
          // database or other service. The connect descriptor received by the listener
          // specified a SID for an instance (usually a database instance) that either
          // has not yet dynamically registered with the listener or has not been
          // statically configured for the listener. This may be a temporary condition
          // such as after the listener has started, but before the database instance
          // has registered with the listener.
          // *Action:
          //  - Wait a moment and try to connect a second time.
          //  - Check which instances are currently known by the listener by executing:
          //    lsnrctl services <listener name>
          //  - Check that the SID parameter in the connect descriptor specifies
          //    an instance known by the listener.
          //  - Check for an event in the listener.log file.
          Hope this helps.

          Good Luck,
          Avi.
          • 2. Re: Oracle 10g JDBC connection refused error
            201187
            Dear Avi,

            Thank you for your reply. I found difficulty to solve this situation.
            When I installed the oracle 10g, I also set 1521 port for listener as oracle 9i used.
            Do you think that caused the problems ?

            I checked listener log files for both oracle 9i and 10g. As you mentioned, in log files of oracle 9i said that

            08-FEB-2006 10:39:01 * (CONNECT_DATA=(SID=biosyscom)(CID=(PROGRAM=)(HOST=__jdbc__)(USER=))) * (ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=2959)) * establish * biosyscom * 12505
            TNS-12505: TNS:listener could not resolve SID given in connect descriptor.

            In the log file of 10g is like that
            08-FEB-2006 10:38:50 * (CONNECT_DATA=(SID=biosyscom)(CID=(PROGRAM=G:\oracle\product\10.2.0\db_2\perl\5.8.3\bin\MSWin32-x86-multi-thread\perl.exe)(HOST=austvagoy)(USER=SYSTEM))) * (ADDRESS=(PROTOCOL=tcp)(HOST=10.10.10.10)(PORT=2957)) * establish * biosysco * 0
            08-FEB-2006 10:40:18 * service_update * biosysco * 0.

            SID of oracle 10g is biosyscom.
            I think when my java application accessed the oracle 10g, it connected to the oracle 9i listener. That's why oracle 9i could not resolved current SID for oracle 1og.

            In addition, I installed oracle 10g in external hard disk drive which is connected by USB device.

            When I logged on Enterprise Managment Control by web, biosyscom database instance is running. I can log on to sqlplus in oracle 10g. But I cannot establish the jdbc connection to oracle 10g.

            Do you think I need to install the oracle 10g in main hard disk drive ?

            Please help.

            Message was edited by:
            shine99
            • 3. Re: Oracle 10g JDBC connection refused error
              Avi Abrami
              shine99,
              It appears that your problem is more to do with installing and configuring Oracle database, rather than with JDBC. Hence I feel this is an inappropriate forum for your question, and it's not my area of expertise, so I can't really help you. I suggest you look for a forum that deals with installation and configuration issues.

              Good Luck,
              Avi.
              • 4. Re: Oracle 10g JDBC connection refused error
                342383
                Hello Avi,
                we are using Oracle 9i RAC .
                We are getting connection refused error when trying to connect to Oracle 9i RAC.
                using JDBC thin drivers.

                1) does Oracle 9i RAC support JDBC thin drivers ?
                2) if App. Server (where jdbc app. running ) is on seperate machine and Oracle RAC on seperate machine, do we need need install any net service from Oracle ?

                We aregetting this error.


                DSRA8040I: Failed to connect to the DataSource. Encountered "": java.lang.Exception: java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153093376)(ERR=12514)(ERROR_STACK=(ERROR=(CODE=12514)(EMFI=4))))DSRA0010E: SQL State = null, Error Code = 17,002

                I would appreciate your help.

                Jahan
                • 5. Re: Oracle 10g JDBC connection refused error
                  dvohra21
                  The Connection refused error is caused because:
                  1.     The database SID specified is incorrect.
                  2.     The database instance has not been started. To start the database instance connect to SQL*Plus as SYSDBA.
                  C:\>sqlplus SYS/<pwd> AS SYSDBA

                  At the SQL prompt start the database instance with the startup command.

                  SQL>startup
                  • 6. Re: Oracle 10g JDBC connection refused error
                    497029
                    if u are in unix system u must see the listener or services that run but first try to change the SID to dev920. if it is not running use unix command to see the service
                    • 7. Re: Oracle 10g JDBC connection refused error
                      490344
                      Hi! I think you cannot use Oracle 9i and Oracle 10g on the same machine. I think there is a problem with the TNS listener. The listener doesn't recognize the way TNS is set up in 10g. If you could de-install 10g, and use 9i it should work fine.
                      • 8. Re: Oracle 10g JDBC connection refused error
                        480891
                        Just IFILE the 9i listener to the 10g listener.
                        • 9. Re: Oracle 10g JDBC connection refused error
                          512297
                          I am also getting refused connections. This happens when I run a test battery using my oracle10gxe instance. Something like 10 tests/sec.

                          I'm opening and closing connections between the tests. The tests are called in a serial way. No Threads.

                          When I put a delay between the tests like, 2tests/sec, there are no refused connections.

                          It seems to me that oracle10gxe has a hard time releasing the resources for each handle.

                          This is the stack trace I get:

                          java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169869568)(ERR=12519)(ERROR_STACK=(ERROR=(CODE=12519)(EMFI=4))))
                               at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
                               at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:156)
                               at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
                               at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:210)
                               at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:251)
                               at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:224)
                               at java.sql.DriverManager.getConnection(DriverManager.java:525)
                               at java.sql.DriverManager.getConnection(DriverManager.java:171)
                          ...

                          []s
                          • 10. Re: Oracle 10g JDBC connection refused error
                            540553
                            Hii Avi,

                            When I call a JSP/Servlet deployed in JBOSS/Tomcat , I encounter the following error. The JSP/Servlet connects to Oracle 10g Express Edition installed locally. The error is not consistant.
                            HTTP Status 500 -

                            --------------------------------------------------------------------------------

                            type Exception report

                            message

                            description The server encountered an internal error () that prevented it from fulfilling this request.

                            exception

                            org.apache.jasper.JasperException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169869568)(ERR=12519)(ERROR_STACK=(ERROR=(CODE=12519)(EMFI=4))))
                            org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
                            org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
                            org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
                            org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
                            javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


                            root cause

                            javax.servlet.ServletException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169869568)(ERR=12519)(ERROR_STACK=(ERROR=(CODE=12519)(EMFI=4))))
                            org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
                            org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
                            org.apache.jsp.jsp.templateView_jsp._jspService(templateView_jsp.java:307)
                            org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
                            javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
                            org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
                            org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
                            org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
                            javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


                            root cause

                            java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169869568)(ERR=12519)(ERROR_STACK=(ERROR=(CODE=12519)(EMFI=4))))
                            oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
                            oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
                            oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333)
                            oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:404)
                            oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:468)
                            oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
                            java.sql.DriverManager.getConnection(Unknown Source)
                            java.sql.DriverManager.getConnection(Unknown Source)
                            org.apache.jsp.jsp.templateView_jsp._jspService(templateView_jsp.java:65)
                            org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
                            javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
                            org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
                            org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
                            org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
                            javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


                            note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.

                            Any help is appreciated.Thanks in advance!!!

                            Regards,
                            • 11. Re: Oracle 10g JDBC connection refused error
                              dvohra21
                              The Connection refused error is caused because:
                              1.     The database SID specified is incorrect.
                              2.     The database instance has not been started. To start the database instance connect to SQL*Plus as SYSDBA.
                              C:\>sqlplus SYS/<pwd> AS SYSDBA

                              At the SQL prompt start the database instance with the startup command.

                              SQL>startup
                              • 12. Re: Oracle 10g JDBC connection refused error
                                558844
                                The problem here is an incompatibility which for all I know Oracle has introduced. The jdbc URL connection string syntax has changed from what it was before. It used to be:

                                jdbc:oracle:thin:@<host>:<port>:<sid>

                                now it is

                                jdbc:oracle:thin://@<host>:<port>/<sid>

                                If it's not like that, then the TNS listener can't resolve it, it doesn't get the SID right. But you can only set it like this if you use the most up to date jdbc driver ojdbc14.jar whose size is supposed to be 1536979 Bytes (not 1.4 MB or 1.3 MB).

                                This is indeed a huge problem as tons of software out there thinks it knows how to construct an Oracle jdbc URL but is now all wrong. We have a TAR open on this subject which is increasingly annoying. My hope is I have just overlooked something and there might be some compatibility mode somewhere.
                                • 13. Re: Oracle 10g JDBC connection refused error
                                  558844
                                  I have this solved for me, and for the sake of the lost I give the detail here.

                                  Did you realize and internalize that SID is an old notion and SERVICE_NAME is new and SERVICE_NAME is not just a beefed-up SID?

                                  There are two forms of JDBC URLs:

                                  Old form: jdbc:oracle:thin:<host>:<port>:<SID>

                                  New form: jdbc:oracle:thin://<host>:<port>/<SERVICE_NAME>

                                  The switch between old and new forms apparently happened at 9iR2,

                                  If you see "foo" (or "FOO") it's a SID, if you see "foo.mydom.net" it's a SERVICE_NAME". Many people relate them and think that SERVICE_NAME = SID + DOMAIN. But not necessarily so.

                                  The answer lies in the server configuration. If the listener.ora file is minimal, it will mediate between the database instance that registers and the clients that connect to port 1521 (or whatever). But that ONLY works with SERVICE_NAME, and that ONLY works with the new style URL and that's only supported by the JDBC driver (even though the filename is NOT different. Be aware that ojdbc14.jar may be old or new, you can only tell from the slightly larger size (1.5 instead of 1.3 or 1.4 MB).

                                  The fix is to add a SID_LIST to the listener.ora file on the server:

                                  SID_LIST_LISTENER = (SID_LIST =
                                  (SID_DESC =(GLOBAL_DBNAME = foo.mydom.net)
                                  (ORACLE_HOME = /usr/oracle/oraclehome)
                                  (SID_NAME = mysidthatilike)
                                  )
                                  )

                                  And note that you can put any SID_NAME of your choosing, it doesn't seem to matter which.


                                  Some of this may be talked about on Metalink in

                                  - Note:76531.1 Service Name Usage in Net8i
                                  - Note: 183905.1 JDBC Thin Connection to Database Fails with ORA-12505/TNS-12505

                                  A final lesser-known feature is that you can also use a full blown connection descriptor on the jdbc URI. For instance:

                                  url="jdbc:oracle:thin:@(DESCRIPTION=
                                  (LOAD_BALANCE=on)
                                  (ADDRESS=(PROTOCOL=TCP)(HOST=host1) (PORT=1521))
                                  (ADDRESS=(PROTOCOL=TCP)(HOST=host2)(PORT=1521))
                                  (CONNECT_DATA=(SERVICE_NAME=service_name)))"

                                  or

                                  url="jdbc:oracle:thin:@(DESCRIPTION=
                                  (ADDRESS=(PROTOCOL=TCP)(HOST=cluster_alias) (PORT=1521))
                                  (CONNECT_DATA=(SERVICE_NAME=service_name)))"
                                  • 14. Re: Oracle 10g JDBC connection refused error
                                    563434
                                    hi, i think that i have the same issue but i note that the app works fine for a while but after a time sends me the error TNS-12505: TNS:listener does not currently know of SID given in connect descriptor at the log file, i start to monitoring the process number and reach the limit of pmon process (default 150) and oracle blocks all entries to database, so i think maybe there is something wrong with the app or the jdbc but i don´t know if is the same issue or an app issue, thanks
                                    1 2 Previous Next