Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet, mysql JDBC connection and Parameters

 
induz sat
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to have multiple JDBC-connections (to mySQL databse) in my servlet.

For each servlet I use:

After establishing JDBC connection to SocialNetwork DataBase, I use insert, and update queries to add/update the records on my userInfo db.



i want the same JDBC connection to use in another servlet[userLogin] in the same application/package.

Is there a way I can create another connection servler/class and import it and use it in all other Httpservlets responsible for registering a new user , checking records, updating records etc..in the same SocialNetwork Db but different tables??

The 'UserLogin' servlet checks two records userName and Password in 'registredUser' table when the user logs-in through a login.jsp page with userName and password.

I am getting input parameters onto the UserLogin servlet from Login.jsp as below


How should i go about checking name and password in terms of sql queries- right now I am trying to use



to make it clear I have 2 tables[ registredUser and UserInfo.
RegistredUser has these colums- UserId, userName, Password, Age and city. user Id is PK and AI.

UserInfo has userId, userName and Password. User Id is PK and AI in this table too.

How can i establish a relation between userID in two different tables and check/authenticate the userName and password??




 
Ivan Jozsef Balazs
Rancher
Posts: 979
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some side notes:

  • Database connections in servlet environments are best used through connection pools.
  • Hardwiring the database parameters into the source code is not good.
  •  
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic