Troubleshooting Database and Connection Pooling Problems
Troubleshooting Database and Connection Pooling Problems
Thu-Giang Pham
Agenda
JDBC Providers
Installed applications use JDBC providers to interact with
databases.
The JDBC provider object supplies the specific JDBC driver
implementation class for access to a specific vendor
database. To create a pool of connections to that database,
you associate a data source with the JDBC provider.
JDBC provider and the data source objects are functionally
equivalent to the J2EE Connector Architecture (JCA)
connection factory, which provides connectivity with a non-
relational database.
Data Source
Is used to obtain connections to a relational
database.
Is analogous to the J2EE Connector Architecture
(JCA) connection factory, which provides
connectivity to other types of enterprise information
systems (EIS).
Is associated with a JDBC provider, which supplies
the driver implementation classes that are required
for JDBC connectivity with specific database.
Multiple data sources with different settings can
associate them with the same JDBC provider
Configuration Requirement
http://publib.boulder.ibm.com/infocenter/wasinfo/v6
r0/topic/com.ibm.websphere.base.doc/info/aes/ae/r
dat_minreq.html
ClassCastException
ClassNotFoundException
NoClassDefFoundException
UnsatisfiedLinkError
See Information Center, section Class loading
exceptions for explanations and troubleshooting
tips.
ClassNotFoundException
ClassCastException
UnsatisfiedLinkError
UnsatisfiedLinkError
If there is no value specified for the native library path in your JDBC
Provider’s configuration, you might get the UnsatisfiedLinkError:
On Windows platforms, set the system environment PATH to include
the path where the *.dll files can be loaded.
On UNIX platforms, you might need to set up the user’s profile to set
the environment variables before starting the WebSphere Application
Server processes.
32-bit versus 64-bit native libraries
32-bit WebSphere Application Server, must use 32-bit JDBC Driver
64-bit WebSphere Application Server, must use 64-bit JDBC Driver
Connection Pooling
J2C Component
Is the WSAS implementation of JCA 1.5.
JCA 1.5
provides a standardized way (Outbound Contracts) for a
J2EE container to provide Connection Management
services, such as Connection pooling, Transaction
Management, and Security Management. Thus any JCA
1.5 compliant Resource Adapter should be able to
interoperate with WSAS.
defines system level contracts (Inbound Contracts) for a
message provider to connect to endpoints (i.e. message-
driven bean applications) in WSAS via a resource
adapter.
defines a contract for the application server to provide
thread management services for resource adapters.
Common Problems
ConnectionWaitTimeoutException
ConnectionWaitTimeoutException
Can occur when servlets are migrated from
v2.2 to 2.3
See technote “Servlet connection to
database fails after migrating from
WebSphere Application Server V4 to V5 and
later versions” for explanation:
http://www-
1.ibm.com/support/docview.wss?&uid=swg
21192666
Connection Leak
A connection leak occurs when the application uses a
connection but it never explicitly calls the close() method on
the connection object to return the connection back to the
connection pool for reuse.
You might have a connection leak if your application receives
exceptions such as
com.ibm.websphere.ce.cm.ConnectionWaitTimeoutExce
ption or
com.ibm.websphere.ce.j2c.ConnectionWaitTimeoutExce
ption when attempting to access a data source or JCA-
compliant resource adapter, respectively.
Trace Specification
ConnLeakLogic=all
Traces details such as the getConnection call stack
for connections that have been in use for a long
time (10 seconds).
Included in ‘WAS.j2c’ trace.
ConnLeakLogic may be used alone, but will only
generate output during FFDC processing on a
ConnectionWaitTimeout scenario
Deadlock
Application requires more than one concurrent connection
per thread, and the database connection pool is not large
enough for the number of threads.
Troubleshooting
Collect Javacores/Javadumps (see MustGather
document for the corresponding version and operating
system)
Use IBM Thread and Monitor Dump Analyzer for Java
Java Technology
Solution
Increase the Maximum Connections value for the
database connection pool by at least one.
Programming model
Improper caching of connection handles
Direct JNDI lookup of connection factory or data source
J2CA0122I: Resource reference {0} could not be
located, so the following default values are used: {1}
Spinning threads from a resource adapter
LTC scope issues
Multiple connections
Connections reserved for long periods
See technote 1217062 and developerWorks article
Default behavior of managed connections in WebSphere
Application Server (See link on References slide)
StaleConnectionExceptions
Statement Cache
Application calls prepareStatement on its
Connection handle. RRA in this example finds the
statement in the statement cache. A wrapper is
created for the PreparedStatement object, attached
to the Connection wrapper, and the new wrapper is
returned to the app
If same prepared statement works the first time
and fails on subsequent time, there is a chance
that the statement cache is corrupt – try disabling
the cache by setting the statement cache size to
zero
Trace Specifications
Trace Analysis
Find primary error (J2CAxxxx or RA-specific message).
Identify J2C, RA, and/or Transaction objects and the WSAS
thread involved.
Follow progress of thread leading up to the problem.
Follow history of significant J2C, RA, and/or Transaction
objects leading up to the problem.
Identify abnormal events or configuration data that would lead
to the problem.
Decide whether the cause lies with configuration, application,
WSAS, or RA.
Summary
References