Results 1 to 5 of 5
  1. #1
    videanuadrian is offline Member
    Join Date
    Dec 2010
    Location
    Bucharest Romania
    Posts
    40
    Rep Power
    0

    Default dataSource configuration

    Hi all,
    i saw that from glassfish you can configure jdbc resources and jdbc connection pools, and i suppose that after that you can use these to connect to database. What will be the advantage of this setup over the conventional setup with connection parameters defined in hibernate.xml and using a driverManaged connection? Also, if i use this type o db connection do i still have to use c3p0 for connection pooling ?

    thanks,

    ps. it seems that in EE it`s recommended to use this container managed approach and in java SE the other one.

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    6

    Default

    i think the container managed database connection pool is preferred, because it abstracts the connection details from the application.
    Consider the use case where if we had a properties file or xml file inside our web application .war file to define the connection to the database. when we deploy the .war file to a given target environment (dev, QA, production), we need to have our build script generate slightly different .war files, containing the required .properties file to define how it should hook up to its specific database.

    and some other brainstorming ideas why container is better.
    - if we ever wanted to promote a .war file from QA-> production, we can't, without having to modify the .war file or build a new .war file.
    - if for some reason the hosting infrastructure changes or requires maintenance such that the database is now located at a new location, the application would require to be redeployed if the configuration was inside the .war file.
    - perhaps for security, it is desired the application developers do not know the production database user/passwords, the .war file is dropped into the box by a system application administrator after they receive it from the developer.
    - if more than one application should require the same database, they can efficiently share the same conainer managed connection pool, instead of each of them having to boot up a pool of their own.
    - the pool connection logic, and jdbc drivers don't have to be contained in your .war file, they can be contained in the application server class path, and upgraded easily (separately) from the applications.

  3. #3
    videanuadrian is offline Member
    Join Date
    Dec 2010
    Location
    Bucharest Romania
    Posts
    40
    Rep Power
    0

    Default

    Hi Travishein and thanks for quick reply.
    I already have some problems when i move the app from test environment to production, due the fact that i have to rebuild it, and this seems to be a good idea.
    sorry for the stupid question that i'm about to ask, but i want to make sure that i fully understand the problem :)
    if i use container managed pool i do not need c3p0 as connection pool manager, right ?

    thank you.

  4. #4
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    6

    Default

    right, most containers like tomcat and glassfish come with some implementation of a JDBC connection pool, tomcat usually has one based on commons-dbcp.

    So you would not need to have the database jdbc jar file or the connection pool (c3p0) jar file in your application.

  5. #5
    videanuadrian is offline Member
    Join Date
    Dec 2010
    Location
    Bucharest Romania
    Posts
    40
    Rep Power
    0

Similar Threads

  1. Datasource problem
    By sridharthanneeru in forum JDBC
    Replies: 7
    Last Post: 03-24-2011, 12:37 PM
  2. DriverManager vs. DataSource
    By drieskn in forum JDBC
    Replies: 4
    Last Post: 02-05-2009, 05:38 AM
  3. JasperReports dataSource.
    By hendrix79 in forum Advanced Java
    Replies: 0
    Last Post: 01-29-2009, 11:54 AM
  4. Cannot set DataSource for RowSet
    By piterskiy in forum JDBC
    Replies: 0
    Last Post: 12-07-2007, 08:58 PM
  5. Datasource
    By samson in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 04-02-2007, 12:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •