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

Connect to db

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • 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
  • 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: 40200
816
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • 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.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic