Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

servlet, mysql JDBC connection and Parameters

 
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??




 
Rancher
Posts: 1041
6
  • 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.
  •  
    Consider Paul's rocket mass heater.
      Bookmark Topic Watch Topic
    • New Topic