Chapter 2. Installation


  1. System Requirements
  2. Setting the CLASSPATH
  3. Loading the Driver
  4. Connecting to the Database

System Requirements

HXTT Cobol packages include a Type 4 JDBC driver. Type 4 indicates that the driver is written in Pure Java, and communicates in the database system's own network protocol. Because of this, the driver is platform independent; once compiled, the driver can be used on any system. HXTT Cobol can run on any platforms with Java VM, which includes Microsoft Windows, Novell Netware, OS2, UNIX, and LINUX. HXTT Cobol supports Personal Java, JDK1.0.X, JDK1.1.X, JDK1.2.X, JDK1.3.X, JDK1.4.X, JDK1.5.X, JDK1.6.X, and JDK1.7.X. HXTT Cobol includes a database engine which can support multi-user access. It supports { UNION | INTERSECT | EXCEPT | MINUS } [ ALL ] query , INNER JOIN, FULL JOIN, LEFT JOIN, RIGHT JOIN, NATURAL JOIN, CROSS JOIN, and subquery which includes single-row subquery, multirow subquery, multiple-column subquery, inline views, and correlated subquery.

Setting the CLASSPATH

When java loads any class, it searches a list known as the classpath. This is a list of directories where classes are placed, or a list of jar files (archives containing classes and other resources) or both. HXTT Cobol driver is a Type 4 driver. You can do this in many different methods, but the most command are:

  1. Setting the CLASSPATH environment variable.
  2. putting it on the command line using the -cp parameter.
  3. placing it in the JVM's lib/ext directory.
  4. extract all files in jar file into the directory of your application.

You can know detailed information about "Setting the Classpath" from your JDK Tools and Utilities. Let's use JDBC3.0 package as a simple sample. To put Cobol_JDBC30.jar into your class path, you should use "export CLASSPATH=/usr/share/lib/Cobol_JDBC30.jar:$CLASSPATH" on Solaris and Linux, and "SET CLASSPATH=\javalib\Cobol_JDBC30.jar;%classpath%" on Windows.

Loading the Driver

Any source that uses JDBC needs to import the java.sql package by using " import java.sql.*;".

HXTT Cobol driver' name is com.hxtt.sql.cobol.CobolDriver, and you can uses it without involving hard coding the driver into your code. You do this by setting the jdbc.drivers system property. For example, for command line apps you can use:
java -Djdbc.drivers=com.hxtt.sql.cobol.CobolDriver yourApp
Then, the JVM upon startup will load the drivers automatically. Some applications (JBoss, Tomcat etc) support a .properties file which they use to save putting this on the command line.

The second method is the most common and involves you loading the driver yourself. It's simple:
From then on you can get connections from DriverManager.
Note: If Class.forName() throws ClassNotFoundException, you should check your classpath.

Connecting to the Database

After the driver has been registered with the DriverManager, you can obtain a Connection instance that is connected to a particular database by calling DriverManager.getConnection(). With JDBC, a database is represented by a URL (Uniform Resource Locator).

                jdbc:cobol:[//]/[DatabasePath][?prop1=value1[;prop2=value2]] (You can omit that "//" characters sometimes)
                        For example:
                                "jdbc:cobol:/c:/data" for Windows driver
                                "jdbc:cobol:///c:/data" for Windows driver
                                "jdbc:cobol:////usr/data" for unix or linux
                                "jdbc:cobol://///" for UNC path
        Remote Access (client/server mode):
                        For example: "jdbc:cobol://" if one CobolServer is run on the 3099 port of
        Compressed Database:(.ZIP, .JAR, .GZ, .TAR, .BZ2, .TGZ, .TAR.GZ, .TAR.BZ2) 
                jdbc url format is the same as embedded url and remote url.
                        For example:
        Memory-only Database:
        URL Database:(http protocol, https protocol, ftp protocol, sftp protocol)
                        For example:
                                "jdbc:cobol:" //Note: FTP site's user/password should be set in ftpURL, and cannot be set in JDBC connection property because user/password JDBC connection property belongs to server/client connection.
        SAMBA Database:(smb protocol)
                        For example:
                                "jdbc:cobol:smb://test1:123@" //Note: SAMBA user/password should be set in SMB url, and cannot be set in JDBC connection property because user/password JDBC connection property belongs to server/client connection.
	UNC path JDBC url:
                        For example:
	Free JDBC url:(Warning: only use it for special project)
                jdbc:cobol:/" or "jdbc:cobol:///". Then you can use some full UNC path names in SQL to visit anywhere where your Java VM has right to access.
                        For instance:
                                select * from \\amd2500\e$\cobolfiles\test;
                                select * from "\\amd2500\d$\coboliles".test;
                                select * from ".".test;

         HXTT Cobol supports seamlessly data mining on memory-only table, physical table, url table, compressed table, SAMBA table in a sql. More details
         is in Advanced Programming chapter.

To connect, you need to get a Connection instance from JDBC. To do this, you use the DriverManager.getConnection() method:

Connection con = DriverManager.getConnection(url, properties);

There are a few different signatures for the getConnection() method. You should see the API documentation that comes with your JDK for more specific information on how to use them. You can specify additional properties to the JDBC driver by placing them in a java.util.Properties instance and passing that instance to the DriverManager when you connect.

Property Name
Default Value
host The remote host on which one CobolServer is running null
port The port on which one CobolServer is listening null
serverType The type of CobolServer on the remote host null
user The user to connect as null
password The password to use when connecting null
charSet To specify a Character Encoding Scheme other than the client default. You can find a Supported Encodings list of file:///c|/jdk1.2/docs/guide/internat/encoding.doc.html. Cp895(Czech MS - DOS 895), Cp620(Polish MS - DOS 620) and Mazovia are extra supported although JVM doesn't support those. null
lockType To specify a compatible lock for other applications. You needn't set that property now since there is no lock from other applications. null
lockTimeout To specify Cobol driver's timeout in milliseconds to wait until processes released record lock or table lock. 0 means a default value, and <0 means no wait. 1000
refreshInterval To specify a a refresh interval setting in seconds for FTP/SFTP database file which determines how long it to discard the content cache. 60
cryptType To specify a crypt type for Table Encryption and Column Level Encryption. All new created table in this connection will become crypted table. You can use DES, TRIDES, BLOWFISH, and AES now. null
cryptKey To specify a crypt key. Without encrypt key, CREATE TABLE won't create crypted table. null
storeCryptKey Indicates whether crypt key is stored in crypted table. If stored, crypted table can be opened automatically in any connection without predefined crypt properites. If not stored, cryptd table can only be opened with the correct key, and none include us can help you in cracking your data without the correct key. false
tmpdir Indicates whether set a temp directory, Default: the value of JVM's "" property. If that value is incorrect, uing the directory of JDBC url. _memory_ means large data in memory. null
delayedClose Indicates the delayed seconds for close transaction. That option is used to avoid frequent close/open table operations for following sqls. Automatic temporary index is disabled when delayedClose<=60s. You can use 0~120 seconds. Default: 3. null
maxIdleTime Indicates the max idle time in minute for remote connection. That option is mainly used to avoid closing automatically idle remote connection for connection pool. Embedded idle connectoin won't be closed automatically except for garbage collection. You can use 1~1440 minutes. Default: 30. null
maxCacheSize Indicates the max memory utilization for per table on automatic temporary index or matched result cache. You can use 16~65536 kilo bytes. Default: 1024. null
fileExtension To specify other suffix as default extension of Cobol data file. DAT
fileDescriptionExtension Indicates whether Cobol driver supports other extension beside 'cpy', 'fd', 'xfd', 'sel', 'cbl', and 'cob' as default file description extension. The supported formats inlcude Cobol source code file, Copybook file, FD file, XFD (EXtended File Descriptor), and SEL file. You can use comma to assign more than one extension, for instance, cobolExtension=CBL,ECOB . null
dir4fileDescription To assign a different directory for file descriptor. If file descriptor is at the same directory of data file, you needn't that connection property. null
dialect To specify a default COBOL dialect. You can use RM, MF, Fujitsu, ACU, IBM, MVS, and CA. null
width4SequenceNumberArea In fixed format, the COBOL source format divides each COBOL source record into 72 columns. Sequence number area are column 1-6. You can use 0 if there's no sequence number area. 6
boundary4source A COBOL source record can extend up to 80 columns in length. The contents of columns 73 to 80 are ignored by the COBOL system. 72
ignoreDirtyData Indicates whether ignores all dirty data and return null value when failed to parse number value or date value. You can use the following code to know where's dirty data in your file.
                            do{//SQState: C0106	Convert dirty data into null value
                                System.out.println("Error Code:"+warnings.getErrorCode());
                                System.out.println("SQL State:"+warnings.getSQLState());
dateFormat dateFormat is used to specify a default parse sequence of date(Default: 'yyyy-MM-dd') format. yyyy-MM-dd
timeFormat timeFormat is used to specify a default parse sequence of time(Default: 'hh:mm:ss') format. hh:mm:ss
timestampFormat timestampFormat is used to specify a default parse sequence of timestamp(Default: 'yyyy-MM-dd hh:mm:ss') format. yyyy-MM-dd hh:mm:ss
decimalFormat decimalFormat is used to specify a default parse sequence of decimal number format. null
decimalSeparator decimalSeparator is used to specify a default character for decimal sign. Different for French, etc. null
groupingSeparator groupingSeparator is used to specify a default character for thousands separator. Different for French, etc. null
ODBCTrimBehavior Indicates whether works like MS Access ODBC driver to ignore tail space characters in condition expression. You can use null, true, false false
caseInsensitive Indicates whether is case insensitve for string comparison. You can use null, true, false false
emptyDecimalAsZero Indicates whether returns empty decimal as zero value. You can use null, true, false false
emptyStringAsNull Indicates whether returns empty string as null value. You can use null, true, false true

When your code then tries to open a Connection, and you get a No driver available SQLException being thrown, this is probably caused by the driver not being in the class path, or the JDBC url not being correct.

To close the database connection, simply call the close() method to the Connection:



Copyright © 1999-2016 Hongxin Technology & Trade Ltd. | All Rights Reserved. |