D
David McDivitt
I want to send an email to people in my unit containing something similar to
the following and I would appreciate comments first:
When putting frameworks together they are made with the idea of being
extensible. Because of that, big nebulous words, concepts, and abstractions
are often used. For the most part Java is plug and play. Objects are
encapsulated. When you ask for something through a method it is given back
to you and you should not care how it comes to exist. If a platform is
enhanced or extended it should make no difference. I do not wish to dispute
the utility of this basic java premise.
When calling the method getPooledConnection, it would imply you are getting
a truly pooled or shared connection. What you are getting is what the
framework wants you to have, and that is within the scope of present
implementation. Java is very robust and it's possible to connect to anything
and everything in the universe from one application. Certainly some of these
resource connections will be grouped together. In my investigation of
existent applications we have, grouping is only done at the resource driver
level. Individual database connections are not pooled or shared.
To support my assertion, if datasource.xml is viewed in the struts
framework, the driver COM.ibm.db2.jdbc.app.DB2Driver can be found. This
driver only works one way. There is no secret, hidden, marvelous, behind the
scenes functionality present in the app server, or the DB2 database, when
this driver is used. There is no reusability of connection objects created
with this driver. If the close method is done on a connection object it
cannot be used again. It is history, toast, gone. Only a new connection can
be instantiated from the DB2 driver, which involves use of a user name and
password, again. If in code you find the close method being called on
connection objects, necessarily, those connection objects go away. Also, on
a connection object, if transaction blocks are used, such apply to the whole
connection object. If threads do somehow share a connection and one starts a
transaction block, it would apply to the other thread as well. There is no
connection within a connection. The same goes for the autocommit property
(dirty writes).
Due to extensibility considerations, and potential grandiose use of
applications, the pooled connection concept might be appropriate, but is
dependent on certain java coding standards within an application and what is
done with connections. It cannot be assumed connections are pooled at a low
level simply because a method name says so.
It is possible to code a singleton, run all connection requests through such
a connection manager, and simply return the same connection object each time
it's asked for. The struts framework does not do this for you. The
application must be coded that way, validity of the connection must be
tested at a timed interval in a separate thread, and no methods can be
called anywhere to modify the connection. A good connection manager might
use three connection objects and return them round robin to callers.
Not understanding connection functionality and assuming certain
functionality exists on faith contributes to database problems.
the following and I would appreciate comments first:
When putting frameworks together they are made with the idea of being
extensible. Because of that, big nebulous words, concepts, and abstractions
are often used. For the most part Java is plug and play. Objects are
encapsulated. When you ask for something through a method it is given back
to you and you should not care how it comes to exist. If a platform is
enhanced or extended it should make no difference. I do not wish to dispute
the utility of this basic java premise.
When calling the method getPooledConnection, it would imply you are getting
a truly pooled or shared connection. What you are getting is what the
framework wants you to have, and that is within the scope of present
implementation. Java is very robust and it's possible to connect to anything
and everything in the universe from one application. Certainly some of these
resource connections will be grouped together. In my investigation of
existent applications we have, grouping is only done at the resource driver
level. Individual database connections are not pooled or shared.
To support my assertion, if datasource.xml is viewed in the struts
framework, the driver COM.ibm.db2.jdbc.app.DB2Driver can be found. This
driver only works one way. There is no secret, hidden, marvelous, behind the
scenes functionality present in the app server, or the DB2 database, when
this driver is used. There is no reusability of connection objects created
with this driver. If the close method is done on a connection object it
cannot be used again. It is history, toast, gone. Only a new connection can
be instantiated from the DB2 driver, which involves use of a user name and
password, again. If in code you find the close method being called on
connection objects, necessarily, those connection objects go away. Also, on
a connection object, if transaction blocks are used, such apply to the whole
connection object. If threads do somehow share a connection and one starts a
transaction block, it would apply to the other thread as well. There is no
connection within a connection. The same goes for the autocommit property
(dirty writes).
Due to extensibility considerations, and potential grandiose use of
applications, the pooled connection concept might be appropriate, but is
dependent on certain java coding standards within an application and what is
done with connections. It cannot be assumed connections are pooled at a low
level simply because a method name says so.
It is possible to code a singleton, run all connection requests through such
a connection manager, and simply return the same connection object each time
it's asked for. The struts framework does not do this for you. The
application must be coded that way, validity of the connection must be
tested at a timed interval in a separate thread, and no methods can be
called anywhere to modify the connection. A good connection manager might
use three connection objects and return them round robin to callers.
Not understanding connection functionality and assuming certain
functionality exists on faith contributes to database problems.