• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

question about getConnection(usr,pwd)

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, there:

I'm using jboss2.4.8, oracle 9i, having a datasource bound to jndi name like "defaultDS". However, for some reason, in my code, I have to using getConnection(userName, password) to get connections from the datasource for different database users.
So, my question is, in Jboss connection pool, does jboss maintain those connections for different database users in the same connection pool? and distinguish them by user name and password when getConnection(user, pwd) is called? or does jboss create new database connection everytime when getConnection(user,pwd) is called?
Just wonder if any overhead implementation may cause performance issue when getConnection(user,pwd) is called.

Thanks a lot in advance if any clues.

Thanks
David Chen
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I created a datsource for user pradeep with max pool size of 2.
In my I called getConnection("scott","xxx") method 3 times. The 3rd call failed implying that the first two connections were pooled and 3rd connection could not be created since the pool size of 2 is violated. This should answer your question that connections for user other than the one mentioned in the Datasource is also pooled.

I carried out the experiment on jboss 3.2.3 and oracle 8i database. You should try for more users like scott on the same pool and share it with us.
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One more experiment on the same pool.

I invoked getConnection("scott"..) twice and returned the same connections to the pool. Now my pool (for user Pradeep ) had 2 connections of user "scott".

I did this

ds.getConnection()//for user pradeep


This called failed saying that credentials did not match. The problem here is my pool has connections for user scott (and not "pradeep") even though Pradeep is the user for which I created the file using the datasource XML file.

David, I suggest that you experiment more because there could be problems that you could face like there are not enough connections for user "X" .
 
David Chen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much Pradeep, and for your test. Actually, we did some similiar tests, and I want to share results here:
1. jboss 2.4.8, Oracle9i, set MaxSize=2, and when jboss started, I have connection by using user, pwd (dba,dba); in my java code, we using getConnection(usr, pwd), so, when we try different users for example user A, B, C. Checked Oracle session, it shows 4 connections there: dba, A,B,C.
2. Same test setting as above, using same users (A) running on 2 applications, checked oracle session, it shows 2 connections there: A,A;
3. Same test setting as above except set MaxSize =1, using same users running on 2 applications at the same time, in oracle session it shows 1 connection there: A. And one of applications catched the exception as Pradeep's test.

So, which means:
1. jboss do create a connection pool and retrieve an instance from the pool (instead of creating new connection each time)when getConnection(usr,pwd) is called;
2. however, it seems at least in jboss2.4.8, jboss maintains different connection pool for different usr,pwd, even if we only bound 1 datasource with jndi name when jboss started;
3. Same parameters like MinSize, MaxSize are used by different connection pools for different usr, pwd.

Really appreciated if anyone have any other further comments

Thanks a lot

David
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David,

Thanks for sharing your test results with us. I would suggest that you have a look at the source code to see how the Connection pooling is implemented in JBoss.
 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I think ur problem relates with setting of the value for attribute name 'Criteria' for the ManagedConnectionPool attribute in the xml file used for deploying the database. Here is a piece of code(from postgres-service.xml) which I am using for Postgres.

<mbean code="org.jboss.resource.connectionmanager.JBossManagedConnectionPool" name="jboss.jca:service=LocalTxPool,name=PostgresDS">
<attribute name="MinSize">0</attribute>
<attribute name="MaxSize">50</attribute>
<attribute name="BlockingTimeoutMillis">5000</attribute>
<attribute name="IdleTimeoutMinutes">15</attribute>

<!--
criteria indicates if Subject (from security domain) or app supplied
parameters (such as from getConnection(user, pw)) are used to distinguish
connections in the pool. Choices are
ByContainerAndApplication (use both),
ByContainer (use Subject),
ByApplication (use app supplied params only),
ByNothing (all connections are equivalent, usually if adapter supports
reauthentication)
-->
<attribute name="Criteria">ByNothing</attribute>
</mbean>

The connection pool differentiates between connections according to the value u set here.

May be this helps. and this is in relation to JBOSS 3.0.8

Cheers
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! What will be the lookup name in such a case?
 
Damanjit Kaur
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the same that u specify in login-config.xml in <application-policy> tag for ur database that u are using.
 
Damanjit Kaur
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but my settings are in respect to jboss3.0.8 but i have been reading things are different in other higher versions for using connection pooling. but still i feel the jndi name should be the same, the one used in above file.
 
today's feeble attempt to support the empire
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic