• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

servlet, mysql JDBC connection and Parameters

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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??




 
Rancher
Posts: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
  •  
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic