tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pid <...@pidster.com>
Subject Re: Using Tomcat7 JDBC Connection Pool
Date Wed, 08 Feb 2012 13:44:02 GMT
On 08/02/2012 12:30, amit shah wrote:
> Thanks for the reply. Responses below.
> 
> On Wed, Feb 8, 2012 at 5:19 PM, Pid <pid@pidster.com> wrote:
> 
>> On 08/02/2012 11:41, amit shah wrote:
>>> I am trying to use the tomcat 7 jdbc connection pool in our application
>> by
>>> using the tomcat-jdbc.jar and tomcat-juli.jar files. The basic connection
>>> pool works fine. I have few questions/clarifications
>>>
>>>
>>>
>>> 1. Executing multiple statements on connection initialization
>>>
>>>             - The pool provides a flexibility to execute a single sql
>> query
>>> when the physical connection is established (initSQL property). I
>> couldn't
>>> find a way to execute multiple sql queries on connection initialization.
>>> The JDBC Interceptor mechanism also doesn't seem to help out. Any
>>> suggestions?
>>
>> Why do you want to execute multiple SQL statements for each connection
>> in the pool?  Normally you want to do the absolute minimum to validate
>> the connection.
> 
> These sql statements are not for validating the connection. We use Oracle
> as our database server. So I wanted to execute  the NLS (National Language
> Setting) queries after the connection is established.

You need to do this because it's multi-tenant (per below) and each
tenant may require different settings?


>>> 2. alternateUserNameAllowed property
>>>
>>> - If a connection is requested with the credentials user1/password1 and
>> the
>>> connection was previously connected using user2/password2, the connection
>>> will be closed, and reopened with the requested credentials. This
>> property
>>> was added as an enhancement to bug
>>> 50025<https://issues.apache.org/bugzilla/show_bug.cgi?id=50025>.
>>> I didn’t understand the reason behind closing the previous connection.
>> Can
>>> the pool not still maintain the previous connection and open a new
>>> connection if the user/password combination do not match?. This way the
>>> same pool can be used for multiple schemas.
>>
>> The old connection is closed so that the current user (who has different
>> credentials) can't then use that connection.
>>
>> If you want to use the old connection, don't pass in new credentials.
>>
>> Note: this is a pool of connections, not a single connection.
> 
>  Can the pool still not close the old connection and maintain a map of
> username/password vs connection. So that the same pool can be used for
> multiple schemas on an Oracle server. This would help out in implementing
> multi-tenant applications where not all environments are active at the same
> time. So the same pool can be used for multiple environments. The
> application can still provides the ability the create a specific pool for
> individual environments. Let me know if anything is unclear.

The pool returns members at random, so how would you know which cached
credentials you were getting?

If the pool kept all of the connections open with different credentials
how can you guarantee availability/performance/SLA for each tenant?

What is the advantage of a single pool in this case?

You are asking the wrong question IMHO.


>>> 3. JMX & Statistics
>>>
>>>             - How can one enable jmx when tomcat 7 jdbc connection pool
>> is
>>> used independently? I tried specifying the jmx vm options
>>> (-Dcom.sun.management.jmxremote
>>> -Dcom.sun.management.jmxremote.port=1617
>>> -Dcom.sun.management.jmxremote.authenticate=false
>>> -Dcom.sun.management.jmxremote.ssl=false)
>>> but they don’t seem to help out? Neither did I found a way to print or
>>> access the pool statistics programmatically. Any suggestions?
>>
>> I don't know the answer offhand, but I assume that an examination of the
>> source code would lead to an understanding of how Tomcat handles this.
>>
>> I had a look at the source code. The ConnectionPool class includes a check
> where a call is made to create an MBean but I couldn't see any calls the
> register the MBean with the MBeanServer. Hence thought of posting a
> question. Any suggestions on the statistics part. There are no methods
> in org.apache.tomcat.jdbc.pool.DataSource for statistics.

What statistics do you want?

The Interceptor mechanism can be used to create bespoke statistics.


>> [key:62590808]
>>
>>
> 


-- 

[key:62590808]


Mime
View raw message