This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Database Connection please help" Watch "Database Connection please help" New topic
Author

Database Connection please help

nash avin
Ranch Hand

Joined: Nov 13, 2003
Posts: 96
Hi,
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
AS
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.
AS
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Database Connection please help
 
It's not a secret anymore!