Witold,

Maybe we have bad assumptions.  Are you assuming that connection pooling is
enabled by default in datasources?

John


On Thu, Feb 28, 2013 at 7:33 AM, Witold Szczerba <pljosh.m...@gmail.com>wrote:

> OK, maybe I am blind or maybe I just do not get it at all. I was reading
> entire JDBC connection pool documentation of TomEE and Tomcat before
> posting to this thread and, even with your explicit links provided, there
> is nothing (at least I cannot find nothing) about the issue I have
> described (not how to handle connection leaks which I do not have).
>
> Can you, please, tell me exactly, I mean exactly where in the docs it is
> described (or other kind of hint), that the configuration like I have
> provided (which is exactly the same as in
> common-datasource-configurations.html) makes broken Tomcat connection pool?
> I mean totally broken (application works now like 100 times faster).
>
> Regards,
> Witold Szczerba
>
> On 28 February 2013 13:00, John D. Ament <john.d.am...@gmail.com> wrote:
>
> > Witold,
> >
> > The entry I added is based on this page in the Tomcat docs:
> >
> >
> http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html#Database_Connection_Pool_(DBCP)_Configurations
> > In addition, at the bottom of the TomEE datasource page you can see it
> > noted (though it's somewhat hidden)
> > http://tomee.apache.org/common-datasource-configurations.html
> >
> > Though I do +1 your sentiment with the configuration.  TomEE ends up
> > reliant on the upstream project's docs.
> >
> > John
> >
> >
> >
> > On Thu, Feb 28, 2013 at 6:10 AM, Witold Szczerba <pljosh.m...@gmail.com
> > >wrote:
> >
> > > One thing I can say just now is that setting DataSourceCreator to DBCP
> > > makes a HUGE difference in performance. That connection pool works as a
> > one
> > > would expect any connection pool to work.
> > > Have not tried the extra interceptors on top of Tomcat Connection Pool,
> > but
> > > as long as I can keep far away from it, I am fine.
> > >
> > > The only thing I would suggest for TomEE project for now would be to
> > > supplement the documentation, so every one, picking TomEE as their app
> > > server of choice, would be warned about the issue.
> > >
> > > Thanks,
> > > Witold Szczerba
> > >
> > >
> > > On 28 February 2013 02:39, John D. Ament <john.d.am...@gmail.com>
> wrote:
> > >
> > > > When I run your example on my local machine, using Tomee 1.5.1 w/
> > jax-rs
> > > > and mysql, I get the same results.  However, switching to dbcp
> pooling
> > > > changes that.
> > > >
> > > > <Resource id="jdbc/resource" type="DataSource">
> > > >   JdbcDriver com.mysql.jdbc.Driver
> > > >   JdbcUrl jdbc:mysql://localhost:3306/ex
> > > >   UserName ex
> > > >   Password abc123
> > > >   JtaManaged true
> > > >   DataSourceCreator dbcp
> > > > </Resource>
> > > >
> > > > And sorry, missing the brackets around your try.
> > > >
> > > > John
> > > >
> > > >
> > > > On Wed, Feb 27, 2013 at 7:58 PM, Witold Szczerba <
> > pljosh.m...@gmail.com
> > > > >wrote:
> > > >
> > > > > Well, all the properties you have mentioned have sane defaults,
> > that's
> > > > why
> > > > > I did not specified them.
> > > > > Also, the try (...) statement (called try-with-resources),
> introduced
> > > in
> > > > > Java7, is calling #close method, so the connection is handled
> > > correctly.
> > > > >
> > > > > Regards,
> > > > > Witold Szczerba
> > > > > ---
> > > > > Sent from my mobile phone.
> > > > > On Feb 28, 2013 1:12 AM, "John D. Ament" <john.d.am...@gmail.com>
> > > wrote:
> > > > >
> > > > > > It seems like you don't have initialSize, maxIdle, maxActive,
> > minIdle
> > > > or
> > > > > > maxWait set.
> > > > > >
> > > > > > Also, I don't think you're returning the connection to the pool.
> > > > > >
> > > > > >
> > > > > > On Wed, Feb 27, 2013 at 6:37 PM, Witold Szczerba <
> > > > pljosh.m...@gmail.com
> > > > > > >wrote:
> > > > > >
> > > > > > > Hi,
> > > > > > > I am facing something very strange. I am not 100% sure if this
> is
> > > > true,
> > > > > > > but everything looks like the connection pool actually
> reconnects
> > > to
> > > > > > > database, I mean it closes the TCP connection and creates new
> > one,
> > > > over
> > > > > > and
> > > > > > > over, instead of reusing connections.
> > > > > > >
> > > > > > > To make sure it is not an issue with my application, I have
> > > created a
> > > > > new
> > > > > > > project with only one class:
> > > > > > >
> > > > > > > /**
> > > > > > >  *
> > > > > > >  * @author witoldsz
> > > > > > >  */
> > > > > > > @Path("/resource")
> > > > > > > @Stateless
> > > > > > > public class Endpoint {
> > > > > > >
> > > > > > >     @Resource(name = "jdbc/resource")
> > > > > > >     private DataSource ds;
> > > > > > >
> > > > > > >     @GET
> > > > > > >     @Produces(MediaType.TEXT_PLAIN)
> > > > > > >     public String hello() throws Exception {
> > > > > > >         try (Connection conn = ds.getConnection()) {
> > > > > > >             //do nothing, just fetch and close the connection
> > > > > > >         }
> > > > > > >         return "Hello!";
> > > > > > >     }
> > > > > > > }
> > > > > > >
> > > > > > > The JDBC resource is actually an Oracle 11g.
> > > > > > >
> > > > > > > Now hear this: each time  I do a HTTP GET:
> > > > > > > http://localhost:8080/app/resource
> > > > > > > I can see a new connection being established and the previous
> one
> > > > > closed,
> > > > > > > used iptraf to monitor.
> > > > > > >
> > > > > > > Also, the:
> > > > > > > --
> > > > > > > SELECT username, sid, serial#,  logon_time, machine, port
> > > > > > > FROM v$session
> > > > > > > WHERE username = 'MY_USER_NAME'
> > > > > > > ORDER BY logon_time;
> > > > > > > --
> > > > > > > result is showing new value in "serial#" column after each HTTP
> > > GET.
> > > > > > >
> > > > > > > What is worth noticing, the already used connection does not
> get
> > > > > > destroyed
> > > > > > > immediately after use. It waits in the pool and is destroyed
> when
> > > new
> > > > > one
> > > > > > > is created. And the new one waits there until yet another one
> is
> > > > > created
> > > > > > > and it goes like this over and over.
> > > > > > >
> > > > > > > I am sure this is the reason my application works really, I
> mean
> > > > really
> > > > > > > slow, when I am developing from home with remote, over VPN,
> > > database.
> > > > > > >
> > > > > > > My environment:
> > > > > > > tomee.xml:
> > > > > > >
> > > > > > > <Resource id="jdbc/resource" type="DataSource">
> > > > > > >   JdbcDriver oracle.jdbc.driver.OracleDriver
> > > > > > >   JdbcUrl jdbc:oracle:thin:@10.169.100.179:1521:orcl
> > > > > > >   UserName test
> > > > > > >   Password test
> > > > > > >   JtaManaged true
> > > > > > > </Resource>
> > > > > > >
> > > > > > > OS:
> > > > > > > Ubuntu 12.10 64 bit,
> > > > > > > Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
> > > > > > > TomEE 1.5.1 JAX-RS
> > > > > > > tested also using:
> > > > > > > TomEE 1.6.0-20130226.041154-13-jaxrs
> > > > > > >
> > > > > > >
> > > > > > > I am attaching source code of the webapp (3.6kB), just
> configure
> > a
> > > > > > > "jdbc/resource" datasource in tomee.xml and deploy it to run it
> > on
> > > > your
> > > > > > own.
> > > > > > >
> > > > > > > Thanks,
> > > > > > > Witold Szczerba
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Reply via email to