As a consultant, developer and database administrator, I've often been asked
to provide coding guidelines and tuning assistance for Java code that
utilizes JDBC. Over time, I've been introduced to or developed standard
coding practices that make JDBC code faster and less error-prone, and easier
to read, understand and use. This article documents some of the more
important "best practices" for using JDBC libraries to perform database
access. As most of my clients are using Oracle database technologies, I've
included several practices that are Oracle-specific.
For the purposes of this article the goals of best practices for JDBC
programming are maintainability, portability and performance. Maintainability
refers to the ease with which developers can understand, debug and modify
JDBC code that they didn't write. Portability refers to the ease with which
JDBC code can ... (more)
While many new database persistence methods for Java programmers have been
developed in recent years (e.g., entity beans, JDO, Hibernate, and many
others), most database access code is still native JDBC. This statement
doesn't express a preference, just an observation. Reasons for JDBC's
popularity include: (1) it was first, (2) it works, and (3) most developers
already know it.
I first documented "best practices" for using the JDBC libraries for JDJ in
April 2000 (Vol. 5, issue 4). For the purposes of this article, the "best
practices" goals for JDBC programming are maintainabi... (more)
As of V8.i, Oracle developers can now write stored procedures, functions,
packages and triggers in Java instead of PL/SQL (Oracle's proprietary
procedural language), which provides some appealing options: We don't have to
learn a proprietary (and thus limited-use) language to write stored objects
for Oracle databases. We can get performance improvements over PL/SQL that
make stored objects much more usable than they've been in the past. We can
write code that's at least somewhat migratable to other database platforms
should we wish to do so. I'll provide guidelines and strategies... (more)