wood burning stoves
The moose likes JDBC and Relational Databases and the fly likes Database Connection please help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Database Connection please help" Watch "Database Connection please help" New topic

Database Connection please help

nash avin
Ranch Hand

Joined: Nov 13, 2003
Posts: 96
I have a servlet that basically connects to the database if the userid and password is correct.
I have a "login.html" page where the user enters the "userid" and "password".The servlet does the checking and grants access to the user.
My question is as follows.As soon as I startup tomcat type in the url login.html,then press the submit button,(both the fields are blank) the servlet says "ok" this is this information is present in the database.It should say "not ok".Hope I question is clear.The code for the servlet is given below.

Regarding the database.The fields in the database are "username" and "password" and it has one tuple
"xyz" and "xyz"

Hope that my question is rightly put.
Thanking you
Billybob Marshall
Ranch Hand

Joined: Jan 27, 2004
Posts: 202
2 problems:
1) move those 'private' variables into your method. Otherwise, 2 near-concurrent hits to the servlet will walk on each other's values, leading to serious bugs.
2) in the method, initialize username and password to null, not to "" - then it will be closer to what you want.
nash avin
Ranch Hand

Joined: Nov 13, 2003
Posts: 96
Thanks for the prompt reply.It did work the way you said it.Will keep posting for errors/doubts.
I agree. Here's the link: http://aspose.com/file-tools
subject: Database Connection please help
It's not a secret anymore!