Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine Database Down vs Invalid User/Pwd

Status
Not open for further replies.

GoTerps88

Programmer
Apr 30, 2007
174
US
One of the requirements of an application I am working on is to display a message to the user if they are unable to connect to the database.

I need to display a "database down" message to the user if something is wrong with the database. I need to send an "invalid username/password" message to the user for invalid logons.

Basically how I am handling this is to parse out the error code and then based on that displaying the relevant message. However, with literally thousands of Oracle error codes out there, I feel this might not be a good idea.

I need to do this on the client because I can't touch the oracle procedures.

I figured it might be a good idea to ask someone who may have handled this situation before.
 

You should be able to "trap" any error in your application code and display the corresponding message.

What is your problem? [ponder]
.

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Obviously I am able to catch the exception. If it were just displaying the message that's easy. I have to send control to a specific Database Down error page if a user cannot connect due to a database problem.

Your code quickly gets messy I think if you are looking for specific error codes. For example, error code 1017 represents an invalid username/pwd, 28001 indicates password expired, 28000 if the account is locked, etc. And if the listener service isn't running or some other issue with the service displays an error code of 0.

I am connecting via JDBC and it appears that I might be able to use the SQLException's SQLState indicator to determine if the connection problem is due to invalid user/account issue or a database connectivity issue. SQLState seems to return null for database connectivity problems.

And it appears that this thread may be better for a Java forum because this really needs to be addressed on the client.

 

True, Java forum would be better. [noevil]
.

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Messy or not, one way or another you're going to have to write some code that says

if error code(s) = bad password then
do this
if error code(s) = database error then
do that

I think I'd take the approach of trapping and dealing with the limited number of bad password error conditions and assume that any other errors that might be raised relate to database problems, ie:

if error code(s) = bad password then
do this
else
do that

If you can display the actual error message you got on the database down page, you're golden.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top