Re: Is Connection Pooling still necessary?

2008-04-17 Thread Christopher Schultz

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

David,

David kerber wrote:
| David kerber wrote:
| Looking at these other posts, and the reference Charles posted, it's
| apparent that I've been getting away without using pooling, even though
| I though I was using it...

Some drivers actually do perform their own pooling (certain Oracle
drivers IIRC), so you might be using pooling even though you have not
explicitly had to do any explicit configuration.

The JDBC API itself neither provides nor promises any pooling services,
so it's up to the implementor of the driver to decide to add that
capability.

JDBC 2.0 added the javax.sql.DataSource interface, which is basically
the basis for pooling (instead of using java.sql.DriverManager). If you
are already using an instance of a DataSource in your own code, you are
probably using pooled (or at least re-usable) JDBC connections whether
you know it or not.

Tomcat's configuration allows you to specify pool size, etc. in a
standard way.

It's unclear to me how to configure a connection pool for, say, MySQL's
Connector/J directly, though MySQL provides a DataSource that claims to
support connection pooling.

The bottom line is that if you are calling DriverManager.getConnection,
you are probably not maximizing the your use of database connections.

Hope that helps,
- -chris

References:
http://java.sun.com/products/jdbc/download.html#spec
http://dev.mysql.com/tech-resources/articles/connection_pooling_with_connectorj.html
(old but still relevant)
http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgHuAwACgkQ9CaO5/Lv0PDnEgCffLPfoSSsHej5H80OEyUTV7Hy
VFUAn3A00oHCv29SSdLeHENqMF9+0zDt
=AwL7
-END PGP SIGNATURE-

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Is Connection Pooling still necessary?

2008-04-17 Thread David kerber

David kerber wrote:

Jonathan Mast wrote:
I'm developing a webapp that is going to be making frequent DB 
operations.

I know that DB connections are expensive and that developers pool
connections to prevent the overhead of frequent instantiation.  Is this
design pattern still necessary?  I ask because I vaguely recall skimming
over an article that stated that this design pattern is not needed 
anymore

with newer versions of Java.

Currently, our webapps make infrequent calls to our database and as 
such I
simply use a static getConnection() method to create new Connections, 
which

I explicitly close at the end of their use.

I realize that our setup, Tomcat 5.5 on Java 1.4.2, will almost 
certainly
require connection pooling.  But does newer versions of Java obviate 
this

need?

Any pointers to relevant (ie. JDK 1.4.2) tutorials on this topic 
would be

greatly appreciated.

Thanks
  
Partly:  I don't believe you need to handle the connection pooling 
yourself, because Tomcat and/or the JRE handle it automatically.  I've 
never done any explicit connection pooling on TC 5.5/Java 1.5, even 
with some large numbers of simultaneous connections, and it works fine.


D


Looking at these other posts, and the reference Charles posted, it's 
apparent that I've been getting away without using pooling, even though 
I though I was using it...


D



-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Is Connection Pooling still necessary?

2008-04-17 Thread Christopher Schultz

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Jonathan,

Jonathan Mast wrote:
| OK, but isn't there all kinds of special configuration required?  The only
| part of J2EE I'm using is JSP, no Servlets, no JNDI, just POJOs (J2SE)
doing
| the database work.  Will Tomcat still automagically handle the pooling for
| me?

No, you have to configure it. Fortunately, configuration is relatively
simple. Read the reference Chuck posted.

| Sounds a little too good to be true, to me.  But I've never done intensive
| DB stuff so...

Even if you only use a pool with a size of 1 connection, it's worth it
to use the infrastructure provided by Tomcat, so you don't have to do it
all yourself. Besides, if the use of your database connections increases
wildly in the future, you only have to increase the size of your
connection pool, instead of re-coding all of your database access code.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgHhgUACgkQ9CaO5/Lv0PCsGQCfQt1xqGn+GVoKo96m7MdH90DL
tnUAn2vnYzRsANgqfX/QmUOQ9u0pd6wv
=Vorp
-END PGP SIGNATURE-

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Is Connection Pooling still necessary?

2008-04-17 Thread Caldarale, Charles R
> Jonathan Mast wrote:
>
> I know that DB connections are expensive and that developers pool
> connections to prevent the overhead of frequent instantiation.
> Is this design pattern still necessary?  I ask because I vaguely 
> recall skimming over an article that stated that this design
> pattern is not needed anymore with newer versions of Java.

I think "skimming" is the key word in the above, leading to
misinterpretation of whatever you were reading.  Connection pooling is
pretty much a necessity in any real-world situation, but it should be
handled by the app server, not individual webapps.

Tomcat DBCP configuration is in the docs:
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.h
tml

 - Chuck

P.S. JSPs are servlets, by the way.


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Is Connection Pooling still necessary?

2008-04-17 Thread David Smith
Pooling still makes sense although in modern servlet containers it's 
provided.  Outside the JVM, there's the overhead of making the 
connection and authenticating that can eat up significant amounts of 
time in busy sites with large numbers of queries to the db.  Those costs 
are completely outside the JVM and would occur in stuff built with any 
of the other languages.


Overall, do some performance testing on your webapp.  If it's need of a 
database is so low that connections timeout and get recycled between 
borrows from the pool, you probably could get away with out the pooling.


--David

Jonathan Mast wrote:


I'm developing a webapp that is going to be making frequent DB operations.
I know that DB connections are expensive and that developers pool
connections to prevent the overhead of frequent instantiation.  Is this
design pattern still necessary?  I ask because I vaguely recall skimming
over an article that stated that this design pattern is not needed anymore
with newer versions of Java.

Currently, our webapps make infrequent calls to our database and as such I
simply use a static getConnection() method to create new Connections, which
I explicitly close at the end of their use.

I realize that our setup, Tomcat 5.5 on Java 1.4.2, will almost certainly
require connection pooling.  But does newer versions of Java obviate this
need?

Any pointers to relevant (ie. JDK 1.4.2) tutorials on this topic would be
greatly appreciated.

Thanks

 




-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Is Connection Pooling still necessary?

2008-04-17 Thread Jonathan Mast
OK, but isn't there all kinds of special configuration required?  The only
part of J2EE I'm using is JSP, no Servlets, no JNDI, just POJOs (J2SE) doing
the database work.  Will Tomcat still automagically handle the pooling for
me?

Sounds a little too good to be true, to me.  But I've never done intensive
DB stuff so...

Thanks

On Thu, Apr 17, 2008 at 12:57 PM, David kerber <[EMAIL PROTECTED]> wrote:

> Jonathan Mast wrote:
>
> > I'm developing a webapp that is going to be making frequent DB
> > operations.
> > I know that DB connections are expensive and that developers pool
> > connections to prevent the overhead of frequent instantiation.  Is this
> > design pattern still necessary?  I ask because I vaguely recall skimming
> > over an article that stated that this design pattern is not needed
> > anymore
> > with newer versions of Java.
> >
> > Currently, our webapps make infrequent calls to our database and as such
> > I
> > simply use a static getConnection() method to create new Connections,
> > which
> > I explicitly close at the end of their use.
> >
> > I realize that our setup, Tomcat 5.5 on Java 1.4.2, will almost
> > certainly
> > require connection pooling.  But does newer versions of Java obviate
> > this
> > need?
> >
> > Any pointers to relevant (ie. JDK 1.4.2) tutorials on this topic would
> > be
> > greatly appreciated.
> >
> > Thanks
> >
> >
> Partly:  I don't believe you need to handle the connection pooling
> yourself, because Tomcat and/or the JRE handle it automatically.  I've never
> done any explicit connection pooling on TC 5.5/Java 1.5, even with some
> large numbers of simultaneous connections, and it works fine.
>
> D
>
>
>
>
>
>
> -
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: Is Connection Pooling still necessary?

2008-04-17 Thread David kerber

Jonathan Mast wrote:

I'm developing a webapp that is going to be making frequent DB operations.
I know that DB connections are expensive and that developers pool
connections to prevent the overhead of frequent instantiation.  Is this
design pattern still necessary?  I ask because I vaguely recall skimming
over an article that stated that this design pattern is not needed anymore
with newer versions of Java.

Currently, our webapps make infrequent calls to our database and as such I
simply use a static getConnection() method to create new Connections, which
I explicitly close at the end of their use.

I realize that our setup, Tomcat 5.5 on Java 1.4.2, will almost certainly
require connection pooling.  But does newer versions of Java obviate this
need?

Any pointers to relevant (ie. JDK 1.4.2) tutorials on this topic would be
greatly appreciated.

Thanks
  
Partly:  I don't believe you need to handle the connection pooling 
yourself, because Tomcat and/or the JRE handle it automatically.  I've 
never done any explicit connection pooling on TC 5.5/Java 1.5, even with 
some large numbers of simultaneous connections, and it works fine.


D






-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Is Connection Pooling still necessary?

2008-04-17 Thread Jonathan Mast
I'm developing a webapp that is going to be making frequent DB operations.
I know that DB connections are expensive and that developers pool
connections to prevent the overhead of frequent instantiation.  Is this
design pattern still necessary?  I ask because I vaguely recall skimming
over an article that stated that this design pattern is not needed anymore
with newer versions of Java.

Currently, our webapps make infrequent calls to our database and as such I
simply use a static getConnection() method to create new Connections, which
I explicitly close at the end of their use.

I realize that our setup, Tomcat 5.5 on Java 1.4.2, will almost certainly
require connection pooling.  But does newer versions of Java obviate this
need?

Any pointers to relevant (ie. JDK 1.4.2) tutorials on this topic would be
greatly appreciated.

Thanks