Is it possible to use sqlplus to programmatically check a database connection (in particular, the SYS account)?
I’m thinking something along this line
- Run sql plus (using Process.Start) with some parameter, giving the sys username and password
- Check the exit code (or even the stdout), whether it is successful or not. The best way I can come up so far is to check the stdout string whether the substring “ERROR” exist, but I don’t think this is very clean
Is this something possible? What parameter do you suggest I use?
The reason I want to do this is because System.Data.OracleClient doesn’t support connection as SYSDBA
This might work
The above script will have the following behaviour:
Note that I haven’t tested the above.
Amendment
The script should be run as follows on unix:
And as follows on windows: