JDBC drivers in the wild

Learn how to deploy, use, and benchmark JDBC driver types 1, 2, 3, and 4

1 2 Page 2
Page 2 of 2
  1. Install the IDS Server

    You'll have to install the IDS Server on the server machine and run it. The IDS Server runs as a service on the server machine.

  2. Create an ODBC DSN

    Create an ODBC DSN for the database on the machine where the IDS Server is running.

  3. Set the classpath

    Install the IDS Driver on the client machine. The classpath setting must include the IDS Driver. It can be set in the command prompt by executing the following command:

    Set %CLASSPATH% = %CLASSPATH%;<IDS
                                           install directory>\classes
                                           
                                        
    
  4. Load the driver

    For the IDS Driver, the parameter to the forName() method is "ids.sql.IDSDriver". The call would look like:

    Class.forName("ids.sql.IDSDriver");
                                           
                                        
    
  5. Establish the database connection

    The JDBC URL is formulated using the following pattern:

    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.
                                           
                                        
    
  6. Calculate the parameters

    The following code could be used to calculate the data access time. The complete result set is traversed in this case:

    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();
                                           
                                        
    

Conclusion

The IDS Driver is a good option because of its small size, low price, and good performance.

MERANT's DataDirect SequeLink Java 5.0

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:

  1. Install the SequeLink Server

    Install the SequeLink Server on the server machine and run the server. It runs as a service on the server machine.

  2. Set the classpath

    Install the SequeLink client on the client machine. The classpath setting must include the necessary jar files in the classpath. The classpath can be set in the command prompt by executing the following command:

    Set CLASSPATH = %CLASSPATH%; <SequeLink
                                           install directory>\lib/sljc.jar
                                           
                                        
    
  3. Load the driver

    For the SequeLink driver, the parameter to the forName() method is "com.merant.sequelink.jdbc.SequeLinkDriver". The call would look like:

    Class.forName("com.merant.sequelink.jdbc.SequeLinkDriver");
                                           
                                        
    
  4. Establish the database connection

    The JDBC URL is formulated using the following pattern:

    "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.
                                           
                                        
    
  5. Calculate parameters

    Parameters such as database connection time, data access time, and record insertion time can be calculated for SequeLink using the code snippets provided in the preceding sections.

Conclusion

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.

Ashna's JTurbo driver

As a type 4 driver, Ashna's JTurbo doesn't require any settings on the client side. Ashna developed JTurbo using 100% Pure Java technology for complete portability across all operating systems, including Microsoft Windows NT, HP-UX, Sun Solaris, IBM AIX, Digital Unix, AS/400, and OS/390 platforms. JTurbo is a fully downloadable, single binary JDBC driver that runs on any Java-enabled platform. Moreover, JTurbo is multithreaded and is designed to scale for all kinds of enterprise-level solutions.

The following steps may be followed to evaluate it:

  1. Set the classpath

    JTurbo comes as a JTurbo.jar file that must be present in the client machine's classpath. It can be set in the command prompt by executing the following command:

    Set %CLASSPATH% = %CLASSPATH%;<JTurbo install
                                           directory>\JTurbo.jar
                                           
                                        
    
  2. Load the driver

    For JTurbo, the parameter for the forName() method is "com.ashna.jturbo.driver.Driver". The call would look like:

    Class.forName("com.ashna.jturbo.driver.Driver");
                                           
                                        
    
  3. Establish the database connection

    The JDBC URL is formulated using the following pattern:

    jdbc:<subprotocol>:<subname>
                                           
                                        
    

    For the JTurbo JDBC driver, the <subprotocol> is JTurbo. The <subname> portion of the URL identifies the database to connect to, as well as the name of the server where the database resides. The <subname> is formulated using the following pattern:

    //<machine Name>/<database name>
                                           
                                        
    

    Connection to the database could be established in this manner:

    stUrl_="jdbc:JTurbo://myServer/myDatabase";
                                           
                                           Connection connection_ = DriverManager.getConnection(stUrl_, "sa", "");
                                           
                                        
    
  4. Calculate parameters

    The following code could be used to calculate the data access time. The result set is not traversed in this case:

    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
                                           java.util.Date dEnd = new java.util.Date();   //get end time
                                           ldiff = dEnd.getTime()-dStart.getTime();   //get time difference
                                                                                  statement_.close();
                                                                               
                                        
    

Conclusion

The JTurbo JDBC driver provides Java developers with an interface to MS SQL Server. As a type 4 driver, it provides a high level of performance with platform independence. It supports the development of Java applets with no client-side platform dependencies.

I-net Sprinta 2000 by I-net Software

I-net Sprinta 2000 is the first JDBC 2.0 driver for Microsoft SQL Server 2000. As such, all new datatypes of SQL Server 2000 are supported by I-net Sprinta. As it is a type 4 driver, it does not require any settings on the client side. Support for JDBC 2.0 is important because it offers a variety of new features such as scrollable and updatable result sets and new data types that allow developers to take advantage of the Java platform's "Write Once, Run Anywhere" capabilities for industrial-strength, cross-platform applications that require access to enterprise data.

Follow these steps to evaluate it:

  1. Set the classpath

    I-net Sprinta comes with a few .class files that must be present in the client machine's classpath. The classpath can be set in the command prompt by executing the following command:

    Set CLASSPATH = %CLASSPATH%;<I-net
                                                                                  Sprinta 2000 install directory>
                                                                               
                                        
    
  2. Load the driver

    For I-net Sprinta 2000, the parameter to the forName() method is "com.inet.tds.TdsDriver". The call would look like:

    Class.forName("com.inet.tds.TdsDriver");
                                                                               
                                        
    
  3. Establish the database connection

    The JDBC URL is formulated using the following pattern:

    jdbc:<subprotocol>:<subname>
                                                                               
                                        
    

    For this driver, the <subprotocol> is inetdae. The <subname> portion of the URL identifies the database to connect to, as well as the name of the server where the database resides. The <subname> portion is formulated using the following pattern:

    jdbc:inetdae:hostname:portnumber?database=MyDb
                                                                               
                                        
    

    A connection to the database could be established in this manner:

    stUrl_="jdbc:inetdae:myServer:1433?database=myDatabase";
                                                                                   
                                                                                  // Let's say myDatabase is the name of the database
                                                                                  // and myServer the server that has the database
                                                                                  Connection connection_ = DriverManager.getConnection(stUrl_, "sa", "");
                                                                               
                                        
    
  4. Calculate the parameters

    The following code could be used to calculate the average time taken to insert database records. The table where the records are inserted has the following columns: int, varchar(255), and datetime:

    Statement statement_ = connection_.createStatement();
                                                                                  long ldiff;
                                                                                  SimpleDateFormat sFormat = new SimpleDateFormat("dd-MMMM-yyyy HH:mm:ss:SSS");
                                                                                  java.util.Date dStart = new java.util.Date();       //get start time
                                                                                  for(int i=0;i<1000;i++)
                                                                                  {
                                                                                  String sDate = sFormat.format(new java.util.Date());
                                                                                     String stInsert="INSERT INTO test VALUES ("+i+",'"+i+"',
                                           '" +sDate+"')";
                                                                                     Statement_.execute(stInsert);
                                                                                  }
                                                                                  java.util.Date dEnd=new java.util.Date();  //get end time
                                                                                  ldiff=dEnd.getTime() - dStart.getTime();  //get difference
                                                                               
                                        
    

Conclusion

The I-net Sprinta 2000, which can be dynamically downloaded, does not require you to install special software on the client or server. Hence, it's a good solution for Internet applications.

Conclusion

The JDBC-ODBC Bridge should be considered only a transitional solution. For large-scale applications you should consider one of the type 2, type 3, or type 4 drivers.

For intranet applications it would be useful to consider type 2 drivers. But since type 3 and type 4 drivers show significantly better performance than type 2 drivers and the trend is towards development of more robust pure-Java drivers, it might be useful to evaluate type 3 or type 4 for intranet situations too.

For Internet-related applications, there is no option but to use type 3 or type 4 drivers. Type 3 drivers are best suited for environments that need to provide connectivity to a variety of DBMS servers and heterogeneous databases and that require significantly high levels of concurrently connected users where performance and scalability are major concerns. Type 4 drivers are generally aimed at the workgroup level.

Nitin Nanda works as a team leader at Quark's India R&D center. He is responsible for the design and development of a three-tier product being engineered in Java with RMI-IIOP as the distributed protocol. Before Quark, he worked with Cadence Design Systems as a senior member of the technical staff.

Learn more about this topic

1 2 Page 2
Page 2 of 2