This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JDBC and the fly likes GUI to verify database login/pwd Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "GUI to verify database login/pwd" Watch "GUI to verify database login/pwd" New topic

GUI to verify database login/pwd

Artemesia Lakener
Ranch Hand

Joined: Jun 21, 2005
Posts: 162
I want to write a very simple GUI asking user to input his/her database uid and pwd. If the login is accepted or rejected, they will see the corresponding pages. Just wondering how to check if the uid/pwd for database is correct ? just try to build a database Connection using the GUI's input uid/pwd ? and if there is no SQLException then it is ok, or it fails ? But it seems SQLException can be caused by other database problem other than incorrect uid/pwd... How to exactly check if the uid/pwd is correct ?

Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1121

You need to check the error code of the "SQLException" to see the exact nature of the exception. I suggest code similar to the following:
[NOTE: Uncompiled and untested.]

Good Luck,
I agree. Here's the link:
subject: GUI to verify database login/pwd
Similar Threads
error in finally
verify database use_id and password
Connection reset by peer:JVM_recv in socket input stream read
How to update a database using web forms
How to maintain the Single Sign-On?.