Scalable Database Server, HiRDB Version 8 UAP Development Guide
The Driver class provides the following functions:
For details about and usage of each method provided with the Driver class, see the applicable JDBC manual. This section explains the database connection procedure and the URL syntax unique to this JDBC driver.
To execute DB connection using the DriverManager class provided by the Java execution environment:
Register the Driver class in the Java Virtual Machine by using the Class.forName method or by registering in the system properties. The package name and Driver class name of the JDBC driver specified for registration are as follows:
Package name: JP.co.Hitachi.soft.HiRDB.JDBC
Driver class name: PrdbDriver
Class.forName("JP.co.Hitachi.soft.HiRDB.JDBC.PrdbDriver"); |
System.setProperty("jdbc.drivers","JP.co.Hitachi.soft.HiRDB.JDBC.PrdbDriver"); |
To connect to the database, use one of the following methods:
Connection con = DriverManager.getConnection(String url, String user, String password) ; or Connection con = DriverManager.getConnection(String url, Properties info) ; |
Specification for internal driver only: Connection con = DriverManager.getConnection(String url) ; |
Driver drv = new JP.co.Hitachi.soft.HiRDB.JDBC.PrdbDriver(); Connection con = drv.connect(String url, Properties info) ; |
In the arguments of the previous methods, specify the information required for database connection.
If a database connection is successful, the JDBC driver returns a Connection object as a result of the method call. If required information is not specified in each argument, or invalid information is specified, the JDBC driver throws an SQLException as a result of the method call.
Table 16-2 lists the arguments of the getConnection method, and Table 16-3 lists the information to be specified for Properties info.
Table 16-2 Arguments of the getConnection method
Argument | Description | Specification |
---|---|---|
String url | URL; For URL, see (3) URL syntax. | R |
String user | Authorization identifier1 | R2 |
String password | Password | O |
Properties info | See Table 16-3. |
Table 16-3 Information to be specified for Properties info
Key | Description | Specification |
---|---|---|
user | Authorization identifier1 | R2 |
password | Password | O |
ENCODELANG | In a Java program, Unicode is used for the character codes. Therefore, during character data processing with HiRDB, the JDBC driver performs mutual character code conversion between HiRDB's character data and Unicodes. For this character code conversion processing, the JDBC driver uses the encoder and decoder provided by the Java Virtual Machine. You must specify the character set names specified by the JDBC driver for the provided encoder and decoder. The settings can be for any character set (such as MS932) supported by Java. For details about this operation if you specify OFF or have not specified anything in Properties info (including the settings using the DataSource.setEncodeLang method and ENCODELANG of the URL), see 16.11.5 setEncodeLang. | O |
COMMIT_BEHAVIOR | When HiRDB commits, this key specifies whether or not the following classes are to remain valid after commit has executed:
|
O |
BLOCK_UPDATE | Specifies whether or not multiple parameters are to be processed at one time when the ? parameter is used to update databases. When this information is omitted, FALSE is assumed.
|
O |
LONGVARBINARY_ACCESS | Specifies the access method for a LONGVARBINARY database (column attribute is BLOB or BINARY). When this key is omitted, REAL is assumed.
|
O |
HiRDB_for_Java_SQL_IN_NUM | Specifies the maximum number of input or input/output ? parameters in the SQL statements to be executed. This is the number of input or input/output ? parameter information items that is acquired during SQL preprocessing. If the actual number of input or input/output ? parameters is greater than this property value, the input or input/output ? parameter information is acquired after the SQL preprocessing. The permitted value range is from 1 to 30,000 (default is 64). Specifying any other value or non-numeric value results in an error. Notes:
|
O |
HiRDB_for_Java_SQL_OUT_NUM | Specifies the maximum number of output items for the SQL statement to be executed. This is the number of output items that is acquired during SQL preprocessing. If the actual number of output items is greater than this property value, the output items are acquired after the SQL preprocessing. The permitted value range is from 1 to 30,000 (default is 64). Specifying any other value or non-numeric value results in an error. Note:
|
O |
HiRDB_for_Java_SQLWARNING_LEVEL | Specifies the retention level of warning information that has been issued during execution of the SQL statement. The permitted warning retention levels are as follows:
For details about the above values, see 16.2.9 SQLWarning class. |
O |
HiRDB_for_Java_CLEAR_ENV | Specifies whether or not the HiRDB client environment definition set as OS environment variables is to be ignored during database connection.
|
O |
PreparedStatement pstmt1 = con.prepareStatement("lock table tb1"); PreparedStatement pstmt2 = con.prepareStatement("lock table tb2"); pstmt1.execute(); //No error occurs. con.commit(); pstmt2.execute(); //An error occurs. pstmt1.close(); pstmt2.close(); |
This section explains the URL syntax supported by the JDBC driver. Do not place any space inside each item or between items in a URL. To specify both an additional connection information item and a database host name item, separate them by a comma (,).
jdbc:hitachi:PrdbDrive[://[DBID=additional-connection-information] [[{://|,}]DBHOST=database-host-name] [[{://|,}]ENCODELANG=conversion-character-set] [[{://|,}]COMMIT_BEHAVIOR=cursor-operation-mode] [[{://|,}]CLEAR_ENV=environment-variable-invalidation-setting]] |
In this example, the path of the HiRDB environment variable group name is /HiRDB_P/Client/HiRDB.ini:
String url = "jdbc:hitachi:PrdbDrive://DBID=@HIRDBENVGRP=/HiRDB_P/Client/HiRDB.ini"; |
String url = "jdbc:hitachi:PrdbDrive://DBID=@HIRDBENVGRP=HiRDB_ENV_GROUP"; |
String url = "jdbc:hitachi:PrdbDrive://DBID=@HIRDBENVGRP=C:\\HiRDB_P\\Client\\HiRDB.ini"; |
String url = "jdbc:hitachi:PrdbDrive://DBID=@HIRDBENVGRP=" + "\"C:\ProgramFiles\\HITACHI\\HiRDB\\HiRDB.ini\""; |
All Rights Reserved. Copyright (C) 2007, Hitachi, Ltd.