This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of React Cookbook: Recipes for Mastering the React Framework and have David Griffiths & Dawn Griffiths on-line!
See this thread for details.
Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Connect to db

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to connect my web application and pages to a db2 database on a unix system.


Right now i can connect using JDBC, my username, password and so on after loggin on using j_security_check.

But it's accessing tomcat-users.xml or whatever.. That's great and all and it works, but I need a way for the database connection to relate to the user's who sign in or not, not by my database connection and authentication.

Some users have access to the DB, while others might not...

I have to figure out a way where after a User signs into the secure part of the website, those username and passwords get stored or are used for the JDBC connection when they click on a table or report that needs to get info or store info in the DB2 Database.

Right now I hardcoded my user name, password and so on in the JDBC connection just to get it to work. I get reports back, can update things and so on. I was playing around with JNDI, but since I'm not the server admin and they haven't always been "tech" or helpful, i'm not sure if that's the best option.

But I need a way for the usernames and passwords to somehow be used as the "username" and "password" part of the jdbc connection. Instead of my username and password.

thanks.
 
Bartender
Posts: 2658
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Isaac,

This is not available in Tomcat.

You would have to write your own Realm implementation to get this functionality.
The JDBC realm available in Tomcat is implemented by class org.apache.catalina.realm.JDBCRealm.

This class looks up the connect parameters in the Tomcat configuration, and connects to the database to verify the user's credentials.

Your class would have to use these credentials, and use them to make the connection.

Once you start with digested passwords, you don't even have a mechanism to retrieve the user's password.

Regards, Jan
 
author & internet detective
Posts: 40722
827
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Isaac,
Welcome to JavaRanch!

I'm going to move this to our Tomcat forum for you so you can get more help.
 
Did Steve tell you that? Fuh - Steve. Just look at this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic