> -----Original Message-----
> From: Eric Emminger [mailto:[EMAIL PROTECTED] 
> Sent: Friday, February 28, 2003 9:01 AM
> To: Turbine Users List
> Subject: Re: Passing TurbineUser info to the database
> 
> 
> Quinton
> 
> > I have need to pass the username of the person logged into my 
> > application to the database.  The only way that I can see to really 
> > accomplish this is to call a stored procedure immediately after 
> > obtaining a pooled connection and calling it again when the 
> connection 
> > is released to clear the name.
> 
> This may be a naive response, but could you just do this in the Login 
> action?
> 

It would be that easy if it were not for connection pooling.  Each time
your application accesses the database, it will get a connection from
the pool and return it.  In order for every database access to have the
current user name, I must execute some code everytime that a connection
is obtained from the pool.  To be safe, I also need to clear the
username when the connection is returned to the pool.

For example, let say that you have some action which will insert a
record into the database from a form submission.  When this action
executes, it will create a new instance of the appropriate OM object,
populate it, and then save it.  During the execution of the same method,
a connection will be obtained from the pool, the jdbc executed, and the
connection is then returned to the pool.

You *could* override the save() method to get the connection, execute a
stored proc to tell the database the current username,
super.save(connection), and then release the connection.  The problem
here is that you will be duplicating the code all over the place!


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to