We help IT Professionals succeed at work.

How to test an jdbc connection in sqlplus?

LindaC
LindaC asked
on
Hi experts:

A programmer told me to test this in sqlplus and I don't know how to test it:

jdbc:oracle:thin:@192.168.112.223:1521:SCSD1.

And this one:  "jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.112.223)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.112.224)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=SCSD_RAC)))"


Scsd1 is one of the instance from a two node Oracle Rac version 10.2.0.3
Scsd_rac is the service name of the ORacle Rac version 10.2.0.3

My tnsnames.ora is working and have the following entries for Scsd1 and scsd_rac:

SCSD1 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.112.223)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SID = SCSD1)
    )
  )

SCSD_RAC =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = hpscs1-vip1)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = hpscs2-vip1)(PORT = 1521))
      (LOAD_BALANCE = yes)
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = SCSD_RAC)
      (FAILOVER_MODE =
        (TYPE = SELECT)
        (METHOD = BASIC)
        (RETRIES = 180)
        (DELAY = 5)
      )
    )
  )
Comment
Watch Question

I would say that it's enough if you just establish a connection to the database using SQLPLUS using SCSD_RAC service name.
Alternatively you can try to connect as following:

sqlplus user/password@"(DESCRIPTION=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.112.223)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.112.224)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=SCSD_RAC)))"

This should also work.

Cheers,
Jarek
Most Valuable Expert 2011
Top Expert 2012

Commented:
you can't test the jdbc with sqlplus itself.  You could create a java stored procedure that does a jdbc connection and then invoke that with sqlplus

Author

Commented:
Thank you Jarek and sdstuber.

Jarek's connection worked.  So I will tell the Programmer to test this.
 

Author

Commented:
Thank you.