Databases Reference
In-Depth Information
Some drivers include the Java finalize() method in their implementation
of the Connection object; others don't. In any case, do not rely on a Java final-
ize() method to close connections because the application must wait on the
garbage collector to run the finalize() method. Again, connections that you
are no longer using are not closed until the garbage collector detects them, which
can tie up memory. In addition, the garbage collector must perform extra steps
each time it runs a collection, which slows the collection process and can further
delay the time it takes for a connection to close. For more information about how
garbage collection works in the JVM, see “Garbage Collection,” page 79.
Obtaining Database and Driver Information Efficiently
Remember that creating a connection is one of the most performance-expensive
operations that an application performs.
Performance Tip
Because of the performance hit your application pays for opening con-
nections, once your application is connected, avoid establishing addi-
tional connections to gather information about the driver and the
database, such as supported data types or database version. For exam-
ple, some applications establish a connection and then call a method in
a separate component that reconnects and gathers information about
the driver and the database. Applications designed as separate compo-
nents, such as J2EE shared libraries or Web Services, can share metadata
by passing the information as an argument to a routine instead of estab-
lishing an additional connection to request that information.
How often do databases change their supported data types or database ver-
sion between connections? Because this type of information typically doesn't
change between connections and isn't a large amount of information to store,
you may want to retrieve and cache the information so the application can access
it later.
 
Search WWH ::




Custom Search