Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need some kind of singleton-functionality on server-side!

Status
Not open for further replies.

frag

Programmer
Dec 7, 2000
321
GB
Hi everybody,

I am trying to solve a design-issue but I can't find the proper solution for it. This is the problem:

We have an java application (client) that connects to a jboss-server and it does some database related tasks (show records in a JTable, add, edit and delete records). Everything fine so far.

The database connection is done by having a config-file for our database and let jboss do the pooling. This works fine as long as we use the method getConnection() of javax.sql.DataSource but in production we will have to use the method getConnection(String username, String password) instead. And here starts the party...

I am looking for a way to provide the server-side with the login data which the user has to enter during the startup of the client. But I only want to provide the data once! That means I don't want to hand over the username and the password in every jndi-call to a bean's method that accesses the database because this is a pain in the a**.

Isn't there any possibility to get a bean-instance that will hold this information persisten until the client disconnects from the server? Actually I am looking for something like a singleton-ejb-class (if you can call it like that). I tried it with a session bean and static variables which will not work in multiuser environment. :(

Any help is appreciated!

Cheers

frag

real_firestorm@gmx.de
 
I don't have any experience with JBoss, but BEA has something called a startup class, that gets loaded when the app server starts. If that were your singleton, it might do what you want. Maybe JBoss has similar functionality.

Chip H.


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
Thank you for your answer chiph... I am sorry to say that I don't get the idea behind the startup class. As I see I would have to provide a name for the class and a hashmap. Will each connected client have his own instance of this class?

I am suprised that there doesn't seem to be a standard solution for this problem. I can't belive that I am the first person who want to do something like registering the user's details (name + pwd) on server side for the duration of a session. *sad*

real_firestorm@gmx.de
 


Create a servlet with startup on load that read usr/pwd infro from a configuration file, set username and password to a class with static variable to hold the value. This should work on any application server.

 
frag,

Correct me if I am wrong, but your client is not a web based client? This is a thick java client making calls to an App Server? I was getting mixed impressions from the replies, and just wanted to clarify what the interface to JBOSS actually was.


I don't think the answer will be that much different if it is a web or java client, but it helps me get my thinking cap on a bit tighter.

A few other questions for you and your application.

1) Are you enforcing security via the database (i.e.: all your Create, Read, Update, Delete (CRUD) privilages are dictated by the database)

2) Do the users supply a login credential from the Java Client when they first start up?

3) What database is being used?

After all of those questions, if you want to look at some interesting reading, you might look into Oracle's Proxy Authentication, which is what I think you are looking for.


-Antharian
 
Hi Antharian,

you are right, it is a thick java client not a webapp.

1) I use the database accounts for the login, that means the user has to provide his database login when using the app. And I select groups/roles depending on the username. Groups are stored in an extra database-table and are project specific, we are not talking about database user roles here!.

2) Don't know exactly what you think of. The user will be prompted to sign in. We have a small swing-based popup window with the login-form.

3) Database is Sybase ASE 12.5

The oracle proxy looks nice but unfortunately it's the wrong vendor. ;)

Cheers

frag

P.s.: What about stateful session beans? Wouldn't that do the trick?

real_firestorm@gmx.de
 
You can probably do it with a "home grown" connection pool mechanism, but you will make no use of the AppServer's connection pooling. You will are essentially re-inventing the wheel.

I am not very familiar with Sybase's JDBC stack, but I have some friends who have been with Sybase for ever. I will ask them.

-Antharian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top