0
votes

We are developing java based web application, which runs on Ubuntu 12.04. At the start of installation, we prompt for Oracle server's Host, Port, user, password & SID details and then passed them to installer to build jdbc:oracle:thin url. Eventually, our installer connects to Oracle and creates some tables. Now I am trying to write a script(shell or python) to quickly verify user entered Oracle settings are correct or not by simply connecting to Oracle and disconnecting before passing those to our installer. I tried to use echo "exit" | sqlplus -L user/password@//host:port/SID | grep Connected > /dev/null but sqlplus easy connect is only taking service-name not SID.

Is there any easy way to test Oracle connectivity. I need to write it in script, which needs to run automatically as a part of installation steps.

Thanks for all the help.

1
The problem is that our jdbc url uses SID and sqlplus is using servicename. I could switch jdbc url to use servicename, but I need to convince my team as SID url been there since the beginning of our application. And I don't know which one is preferable way to connect- SID or ServiceName?user1366786

1 Answers

0
votes

Read https://asktom.oracle.com/pls/asktom/f?p=100:11:0::NO::P11_QUESTION_ID:45033135081903

Oracle listener is expected to listen to your request for connection.

Here is the copy of Tom's answer

[tkyte@desktop tkyte]$ sh -vx test.sh sqlplus 'scott/tiger@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=152 1)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ora9ir2.kyte.com)))'

Use your host, port and service_name.