Instead, i BATIS uses a pool of connections that are kept open and shared by all
users of the application.
Many vendors provide pooled versions of their drivers, but one problem is that
the features and configuration of the pools are as varied as the implementations.
The Jakarta Commons Database Connection Pool ( DBCP ) project is a wrapper
that makes it possible to easily use any JDBC driver as part of a connection pool.
Caching data in a multiuser environment can be tricky. Caching data in a multi-
server environment makes the multiuser environment look simple.
To deal with this problem, i BATIS provides an implementation of caching that
uses the OpenSymphony cache ( OSC ache). OSC ache can be configured to cluster
across multiple servers to provide scalability and fail-over support.
Now that we've looked at some of the features you can configure in i BATIS ,
let's add it to your application!
3.4 Adding iBATIS to your application
Once you've configured i BATIS , the only change required to make it available to
your application is to add it (and any other dependencies you choose) to your
compile-time and runtime classpaths. Let's start with a look at the classpath.
Every computer system needs a way to find what it needs to work. Just like the
$PATH variable on Linux or %PATH% variable on Windows, Java has a path that it
uses to find its required components that is called the classpath .
In the early days of Java, you would set a CLASSPATH environment variable.
While this still works, it is messy because it is inherited by every Java application on
The Java Runtime Environment ( JRE ) also has a special lib/ext directory that
can be used, but this is not recommended except for a few special cases because
all classes in this directory are shared by all applications that use the JRE . We rec-
ommend that you don't put i BATIS in that directory.
So how do you make i BATIS available to your application? There are a couple
Using iBATIS with a stand-alone application
For a stand-alone application, you can set the classpath in a startup script. This is
a reasonable approach used by many applications. For example, if you have a
stand-alone application that is console based, you would add the i BATIS JAR s to
the classpath in Linux using the -cp switch, like this: