Is this code using connection pooling? :-)

Discussion in 'Java' started by Simon Harvey, Jul 21, 2003.

  1. Simon Harvey

    Simon Harvey Guest

    Hi there,

    I have copied the following code which seems to work in my webapp:

    Context init = new InitialContext();
    Context ctx = (Context) init.lookup("java:comp/env");
    DataSource dataSource = (DataSource) ctx.lookup("jdbc/datasource");


    The reason why I have done this is because I want to use connection pooling
    and I have made the necessary changes to tomcat to support this. But my
    question is simply, assuming that I have done everything correctly, with the
    code above, am I know ready to start getting pooled connections when i ask
    the datasource?

    The reason why I ask is because I have seen code that makes specific
    reference to ConnectionPools and so on, but as you can see, the code above
    says nothing about pools at all. I did copy the code from an article on CP
    so I'm sure it is, but I just need to confirm and ask why some examples are
    dong in a different way?

    Doing it this way, does a datasource automatically provide connection
    pooling? Do they all do that? If some don't, what happens - does the code
    need changed?


    Thanks everyone

    Take care

    Simon
    Simon Harvey, Jul 21, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Trevor Hartman

    connection pooling

    Trevor Hartman, Jul 28, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    548
    Mark Heimonen
    Jul 28, 2003
  2. Chris Szabo

    connection pooling error

    Chris Szabo, Aug 19, 2003, in forum: ASP .Net
    Replies:
    6
    Views:
    1,864
    Chris Szabo
    Aug 19, 2003
  3. William \(Bill\) Vaughn

    Re: SqlConnection and connection pooling

    William \(Bill\) Vaughn, Nov 14, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    486
    William \(Bill\) Vaughn
    Nov 14, 2003
  4. =?Utf-8?B?UGllcnNvbiBD?=

    Connection Pooling, Dispose/Close/Using

    =?Utf-8?B?UGllcnNvbiBD?=, Oct 14, 2004, in forum: ASP .Net
    Replies:
    9
    Views:
    4,586
    speedy
    Nov 26, 2008
  5. Replies:
    2
    Views:
    628
Loading...

Share This Page