Class JDBCDriver

  • java.lang.Object
  • All Implemented Interfaces:

    public class JDBCDriver
    extends java.lang.Object
    implements java.sql.Driver
    A JDBC 3.0 driver that accesses DB2 for IBM i databases.

    The jtopenlite driver is designed to provide a JDBC driver suitable for use on mobile devices. Because of this, the following features are not supported.

    • No JDBC 4.0 support
    • No ResultSet positioning (other than
    • No output parameter support for stored procedure calls
    • No lob support
    • No XML support
    • Minimal connection properties -- i.e. Only SQL naming, no translate binary, ...
    • No SQLArray support
    • No JDBC escape syntax support
    • No prepared statement batching
    • No PreparedStatement metadata
    • No Autogenerated keys support
    • No support for MIXED ccsids
    • No support for double byte CCSIDs (except for unicode 1200 and 13488)
    • No support for BIDI ccsids
    • No support for multiple result sets from stored procedures

    To use this driver, the application or caller must register the driver with the JDBC DriverManager. This class also registers itself automatically when it is loaded.

    After registering the driver, applications make connection requests to the DriverManager, which dispatches them to the appropriate driver. This driver accepts connection requests for databases specified by the URLs that match the following syntax:


    The driver uses the specified system name to connect to a corresponding IBM i system.

    Only the following properties are supported

    Property Description Choices Default
    user Specifies the user name for connecting to the server. server user none
    password Specifies the password for connecting to the server system password none
    secure Specifies whether a Secure Sockets Layer (SSL) connection is used to communicate with the server
    • "true" (encrypt all client/serve communication)
    • "false" (encrypt only the password)
    debug Specifies whether debug information should be recorded
    • "true" (debug information is recorded)
    • "false" (no debug information is recorded)

    The following example URL specifies a connection to the database on system


    The following is a simple JDBC program

    import java.sql.*;
    public class RunSql {
       public final static String PROMPT="ENTER SQL STATEMENT or exit > ";
       public static void main(String[] args) {
               try {
                       String url = args[0];
                       String userid = args[1];
                       String password = args[2];
                       Connection connection = DriverManager.getConnection(url, userid, password);
                       Statement statement = connection.createStatement();
                       BufferedReader reader = new BufferedReader(new InputStreamReader(;
                       String line = reader.readLine().trim();
                       while (! line.equalsIgnoreCase("exit") ) {
                               try {
                                       boolean results = statement.execute(line);
                                       if (results) {
                                               ResultSet rs = statement.getResultSet();
                                               ResultSetMetaData rsmd = rs.getMetaData();
                                               int columnCount = rsmd.getColumnCount();
                                               StringBuffer sb = new StringBuffer();
                                               while ( {
                                                      for (int column = 2; column <= columnCount; column++) {
                               } catch (SQLException sqlex) {
                                       System.out.println("SQLException caught");
                               line = reader.readLine().trim();
               } catch (Exception e) {
                       System.out.println("Fatal error occurred");
                 System.out.println("Usage: java JDBCURL USERID PASSWORD");
    • Constructor Detail

      • JDBCDriver

        public JDBCDriver()
    • Method Detail

      • acceptsURL

        public boolean acceptsURL(java.lang.String url)
                           throws java.sql.SQLException
        Specified by:
        acceptsURL in interface java.sql.Driver
      • connect

        public java.sql.Connection connect(java.lang.String url,
                                  java.util.Properties info)
                                    throws java.sql.SQLException
        Specified by:
        connect in interface java.sql.Driver
      • getMajorVersion

        public int getMajorVersion()
        Specified by:
        getMajorVersion in interface java.sql.Driver
      • getMinorVersion

        public int getMinorVersion()
        Specified by:
        getMinorVersion in interface java.sql.Driver
      • getPropertyInfo

        public java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String url,
                                                    java.util.Properties info)
        Specified by:
        getPropertyInfo in interface java.sql.Driver
      • jdbcCompliant

        public boolean jdbcCompliant()
        Specified by:
        jdbcCompliant in interface java.sql.Driver
      • toString

        public java.lang.String toString()
        toString in class java.lang.Object