Some reader favorites:
EJB fundamentals and session beans
Create a scrollable virtual desktop in Swing
Wizard API updated!
Tim Boudreau has released a new version of the Swing Wizard library (version 0.997) that fixes the WizardException bug reported in JavaWorld's recent Open Source Java Project profile. The article's examples have been reworked to test out the new, improved WizardException. Thanks, Tim, for this helpful fix!
Open Source Java Projects: The Wizard API
While writing JDBC applications, developers generally start with JDBC-ODBCBridge to connect to databases. But when an application reaches some advanced stage, for example, when it needs to support multithreading, the JDBC-ODBCBridge poses a few problems. So, the need arises for a robust JDBC driver. In that case, the type of driver depends on quite a few parameters: whether the application is Internet or intranet based, whether it needs to support heterogeneous databases, the number of concurrent users, and so on.
In the first section of this article, we'll look at the basic architecture underlying the four JDBC driver types and enumerate the pros and cons for choosing one type over another -- information you can use to decide what type of JDBC drivers will be best suited for your specific application.
In the second section, we'll see evaluations of five specific industry-standard drivers: Sun's JDBC-ODBC Bridge, IDS Software's IDS Driver, Ashna's JTurbo, I-net Software's I-net Sprinta, and MERANT's SequeLink. I have also provided the steps required to evaluate each driver, as well as code snippets for specifying the classpath, loading the driver, establishing a database connection, and retrieving and inserting records. You may find it useful to use the code snippets provided in your evaluation program and follow these steps to determine benchmarks suited to your software and hardware requirements.
JDBC drivers are divided into four types or levels. Each type defines a JDBC driver implementation with increasingly higher levels of platform independence, performance, and deployment administration. The four types are:
The type 1 driver, JDBC-ODBC Bridge, translates all JDBC calls into ODBC (Open DataBase Connectivity) calls and sends them to the ODBC driver. As such, the ODBC driver, as well as, in many cases, the client database code, must be present on the client machine. Figure 1 shows a typical JDBC-ODBC Bridge environment.

Figure 1. Type 1: JDBC-ODBC Bridge
JDBC driver type 2 -- the native-API/partly Java driver -- converts JDBC calls into database-specific calls for databases such as SQL Server, Informix, Oracle, or Sybase. The type 2 driver communicates directly with the database server; therefore it requires that some binary code be present on the client machine.

Figure 2. Type 2: Native-API/partly Java driver
JDBC driver type 3 -- the net-protocol/all-Java driver -- follows a three-tiered approach whereby the JDBC database requests are passed through the network to the middle-tier server. The middle-tier server then translates the request (directly or indirectly) to the database-specific native-connectivity interface to further the request to the database server. If the middle-tier server is written in Java, it can use a type 1 or type 2 JDBC driver to do this.

Figure 3. Type 3: Net-protocol/all-Java driver
The native-protocol/all-Java driver (JDBC driver type 4) converts JDBC calls into the vendor-specific database management system (DBMS) protocol so that client applications can communicate directly with the database server. Level 4 drivers are completely implemented in Java to achieve platform independence and eliminate deployment administration issues.

Figure 4. Type 4: Native-protocol/all-Java driver
To evaluate the performance of five industry-standard drivers based on parameters such as average connection time, data retrieval time, and record insertion time, I created a sample database in SQL Server 7.0. I picked industry-standard JDBC drivers representing various driver types. Note: I didn't test any type 2 drivers because they are not readily available in the market, and I wanted to stick with pure-Java drivers for this article.
To perform the tests, I downloaded and deployed the trial versions of these drivers; then I performed several tests on each so as to determine performance measures under similar software and hardware environments. Note that the readings could vary for other environments. That being said, the results here provide relative information to evaluate each type of driver.
The following JDBC drivers were tested:
The observations made are given in table 1.
| JDBC Driver/Requirement | JDBC-ODBC Bridge |
IDS Driver | SequeLink | JTurbo 1.22 | I-net Sprinta |
|---|
| Vendor | Comes with Sun JDK | IDS Software | MERANT | Ashna Inc. | I-net Software |
|---|
| Type of driver | 1 | 3 | 3 | 4 | 4 |
|---|
| Footprint (compressed) | - | 114 KB | 269 KB | 107 KB | 42 KB |
|---|
| Database connection time (ms) | 55 | 22 | 65 | 25 | 190 |
|---|
| Data retrieval tme (ms)(33,000 records) | 10 | 5 | 10 | 905 | 675 |
|---|
| Fetch & traversal time (ms) (33,000 records) | 865 | 18,700 | 3,500 | 910 | 560 |
|---|
| Data insertion time (ms) (1,000 records) | 3,700 | 3,000 | 3,500 | 3,600 | 3,050 |
|---|
The database table on which the tests have been performed has columns: int, varchar(255), and datetime. The test conditions were as follows:
| Test conditions |
|---|
| Platform: | Windows NT 4.0 |
| Computer with Java VM: | Pentium III |
| SQL Server 7.0: | Pentium III |
| JVM: | JDK 1.2.1 |
Now let's look at the description of these drivers and the general settings required to evaluate them.
The JDBC-ODBC Bridge by Sun's JavaSoft -- a type 1 driver -- results from a joint effort between JavaSoft and MERANT. Available in the Java Developer Kit (JDK), this product leverages the large number of ODBC drivers available and has provided some momentum for JDBC to become widely accepted in a short time frame.
Follow these steps to evaluate it:
forName() static method of the Class class. forName() takes one string parameter: the name of the driver along with its package. For JavaSoft's JDBC-ODBC Bridge, this string is
"sun.jdbc.odbc.JdbcOdbcDriver". Therefore, the call would look like:Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
DriverManager.getConnection() method. This method's first argument is a string that contains the JDBC URL for the database. The second and third parameters
are the user name and password, respectively.A JDBC URL is formulated using the following pattern:
jdbc:<subprotocol>:<subname>
A connection to the database could be established in this manner:
String stUrl_= "jdbc:odbc:myDSN"; // let's say myDSN // is the name of ODBC DSN Connection connection_ = DriverManager.getConnection(stUrl_, "sa", "");
long ldiff; java.util.Date dStart = new java.util.Date(); //get start time //set up connection to a specified database String stUrl_= "jdbc:odbc:myDSN"; connection_ = DriverManager.getConnection(stUrl_,"sa",""); java.util.Date dEnd = new java.util.Date(); //get end time //get time difference, which is time taken for connection ldiff = dEnd.getTime()-dStart.getTime();
The JDBC-ODBC Bridge is a good starting point for learning JDBC. However, it should be considered a transitional solution, since it is not suitable for large-scale applications.
The IDS Driver is a type 3 driver with the IDS Server as its backend. Database queries and results are sent back and forth between the IDS Driver and the IDS Server. As it is a 100% Pure Java implementation, the driver guarantees the "Write Once, Run Anywhere" promise of Java. Indeed, it runs in all Java-enabled browsers, the Java Plug-in, and the JDK, plus all your favorite Java development tools.
IDS Server supports Oracle (native OCI or ODBC), Sybase (native CT-Lib or ODBC), Informix, MS SQL Server, MS Access, ODBC, FoxPro, dBase, DB2, Ingres, mSQL, MySQL, PostgreSQL, Yard-SQL, and so on.
The following steps could be used to evaluate the IDS Driver:
Set %CLASSPATH% = %CLASSPATH%;<IDS install directory>\classes
forName() method is "ids.sql.IDSDriver". The call would look like:Class.forName("ids.sql.IDSDriver");
jdbc:<subprotocol>:<subname>
For the IDS Driver, the <subprotocol> is ids. The <subname> portion of the URL identifies the database to connect to, as well as the name of the server where the IDS Server is running.
The <subname> is formulated by using the following pattern:
host_address/conn?dbms=odbc&dsn='data source' // Here, host_address is the IP address and port // number of the installed IDS Server, for example, // www.foo.com:12.
A connection to the database could be established in this manner:
stUrl_="jdbc:ids://myServer:12/conn?dsn='myDSN'"; Connection connection_ = DriverManager.getConnection(stUrl_, "sa", ""); // Let's say myDSN is the name of the ODBC DSN // and myServer the server that where IDS Server is installed.
Statement statement_ = connection_.createStatement();
long ldiff;
java.util.Date dStart = new java.util.Date(); //get start time
ResultSet rs = statement_.executeQuery("SELECT * FROM myTable"); //execute
query
while(rs.next()); // traverse the whole record set
java.util.Date dEnd = new java.util.Date(); //get end time
ldiff = dEnd.getTime()-dStart.getTime(); //get time difference
statement_.close();
The IDS Driver is a good option because of its small size, low price, and good performance.
SequeLink Java 5.0 is a 100% Pure Java certified driver that supports all major platforms and databases. This type 3 driver implements the full JDBC 2.0 specification and ensures comprehensive database support and complete compatibility across the latest browsers and Java servers.
The driver includes a JDBC client and a data access server. It supports MS SQL Server, Oracle, and DB2 on OS/390 with centralized configuration, monitoring, and management, as well as advanced security features.
Let's look at the steps to evaluate the SequeLink JDBC driver:
Set CLASSPATH = %CLASSPATH%; <SequeLink install directory>\lib/sljc.jar
forName() method is "com.merant.sequelink.jdbc.SequeLinkDriver". The call would look like:Class.forName("com.merant.sequelink.jdbc.SequeLinkDriver");
"jdbc:sequelink://<host_address>:port number;databaseName=database name"
Here, host_address is the IP address of the machine where the SequeLink server is running, and port number is the port of the installed SequeLink Server (for example, www.foo.com:12).
A connection to the database could be established in this manner:
"jdbc:sequelink://myServer:4006;databaseName=myDb"; // Let's say myDb is the name of the database in SQL Server // and myServer is the server where SequeLink Server is installed.
SequeLink is suitable for organizations with several concurrent clients and heterogeneous databases. In such a scenario, it is a better solution than using several DBMS-specific and thin-client JDBC drivers.
Free Download - 5 Minute Product Review. When slow equals Off: Manage the complexity of Web applications - Symphoniq
![]()
Free Download - 5 Minute Product Review. Realize the benefits of real user monitoring in less than an hour. - Symphoniq