Datasource Connection Pool c3p0

Discussion in 'Java' started by Saburo, Jun 27, 2008.

  1. Saburo

    Saburo

    Joined:
    Jun 27, 2008
    Messages:
    1
    Hello all,
    first thing : I am not really a java expert, coding a bit -enjoying it- but there are some things that I do not understand.

    I am trying to design and code an application (using tomcat 5, with servlets, no beans at the moment) that uses a repository (most likely mysql, but generally a database) and may need to perform many queries against other "n" databases with connections defined by "powerusers".

    Looking in this forum and googling around a bit I discovered it would be good to use cp30 with ComboPooledDataSource.
    I tested it and it works, so far so good.
    Now the problem(s) :

    1) I understood (from some posts in this forum) that it is considered better to define the resources in the server.xml file rather than create them dynamically.
    It would be quite inconvenient for my app as database connections may be defined by users with the right auth level. Is there, for such a situation, a better solution than bind jndi names in the sourcecode (pars are actually stored in the app repository)?

    2) I discovered that ctx.lookup is also an expensive thing to do... then I am in trouble here.
    Someone suggested to create a datasource and keep it alive, setting it in the init().
    That may work for the repository, not sure how to handle the other "n" connections. (a list, an array... whatever).
    How can I create those objects and keep them "alive" for my app? Should I use a listener servlet? (ok, I told you I am not an expert...)

    Any suggestion is welcome.
    Thanks in advance.

    Francesco
    Saburo, Jun 27, 2008
    #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. Sean Nolan

    Trap "connection pool" errors

    Sean Nolan, Jul 11, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    391
    David Browne
    Jul 11, 2003
  2. Linus Nikander
    Replies:
    5
    Views:
    527
  3. Chris Smith

    Connection Pooling - c3p0 - Tomcat.

    Chris Smith, Dec 16, 2004, in forum: Java
    Replies:
    6
    Views:
    19,777
    simplyjava
    May 31, 2008
  4. Wei  Lu
    Replies:
    2
    Views:
    5,840
    Wei Lu
    Feb 16, 2009
  5. Rick Lawson
    Replies:
    8
    Views:
    783
    Graham Dumpleton
    Jul 17, 2009
Loading...

Share This Page