Oracle9i JDBC – Connection refused

I call a Java program in Nagios to test if my database is responding. It is required to test the JDBC connection. The Java program accepts four command line arguments: user, password, hostname, and database.

JdbcThinCheckup mike mike xxx.xx.xx.xxx niku

Added a new service to Nagios to check a database and was getting the error below.

Error: Io exception: Connection refused (DESCRIPTION=(TMP=)(VSNNUM=153094144)(ERR=12505)
(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))

Turns out I was using the alias “nikuprod” found in the tnsnames.ora file rather than the database name “niku”. JDBC doesn’t utilize the tnsnames.ora file. Not sure why that didn’t occur to me yesterday. Brain fart maybe?

NIKUPROD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS=(PROTOCOL=TCP)(HOST=myhost)(PORT=1521))
)
(CONNECT_DATA =
(SERVICE_NAME = NIKU)
)
)

Wasted some time trying to resolve this error by not paying attention. At least I’ll be able to refer back to my blog entry when this happens again a year from now.

6 Responses to “Oracle9i JDBC – Connection refused”

  1. masurie lim Says:

    this is whats on my tnsnames.ora:

    NEW1.METATEC.COM =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = oracleprod01)(PORT = 1521))
    )
    (CONNECT_DATA =
    (SERVICE_NAME = new1.inoveris.com)
    )
    )

    and this is whats on my properties file:

    project.db.url=jdbc:oracle:thin:@oracleprod01:1521:new1.inoveris.com

    and i still got the error you got:

    Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153094144)(
    ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))

    would you mind telling me whats wrong with the setup

    thank you

  2. mrothouse Says:

    What is the value of the db_name parameter in your database?

    select value from v$parameter where name=’db_name’;

    Try using that value instead of ‘new1.inoveris.com’. Please let me know if that corrects your problem.

    • dchu Says:

      [select value from v$parameter where name=’db_name’;]

      This worked for me. Connecting with the TNS name failed. The TNS name and the db_name turned out to be different. Connecting with the db_name was successful.

  3. Bernhard Kern Says:

    i tried the following value and now it works

    select value from v$parameter where name = ‘instance_name’

  4. Dayane Says:

    Error en la conexion con la BDD ORACLE: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153094144)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
    I have a aplication with Apache Tomcat, jsp , servlet and Jdk 1.5update 13 mys tns is like :
    ANDINA.ANDINATEL.INT =

    (DESCRIPTION =

    (ADDRESS_LIST =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.17.222.71)(PORT = 1521))

    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.17.222.72)(PORT = 1521))

    (LOAD_BALANCE = yes)

    )

    (CONNECT_DATA =

    (SERVICE_NAME = ANDINA)

    (FAILOVER_MODE = (TYPE=SELECT)(METHOD=BASIC))

    )

    my conection from my aplication java to oracle 9i is
    conO = DriverManager.getConnection(“jdbc:oracle:thin:CO_ALCADSL/CA16012009@172.17.222.71:1521:ANDINA1″);// URL
    anybody knows what´s wrong with the conection
    the oracle is 9i the jdk is 1.5update 13 and the driver jdbc to oracle9i is classes12.jar
    please your help
    co

  5. Dayane Says:

    I get it !! Maybe you can check with this because the conection with oracle would be RAC.it is different
    “jdbc:oracle:thin:@ (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = nodo_1)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = nodo_2)(PORT =1521)) (LOAD_BALANCE = yes) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = miservicio) (FAILOVER_MODE = (TYPE = SELECT) (METHOD = BASIC) (RETRIES = 180) (DELAY = 5))))”, “username”, “password”

Leave a Reply