1/11/2015

esProc Integration & Application: Deploying JDBC

Java programs can call esProc via JDBC. It is necessary for programmers to know how to deploy the esProc JDBC and familiarize themselves with the detailed configuration information.

1Basic steps

The following instructions need to be followed to deploy the esProc JDBC:

1)  Load necessary jars
Load the jars needed by esProc when launching a Java application. These jars can be placed under the WEB-INF/lib directory in the Web application environment. There are five basic jars necessary for esProc JDBC, all of them can be found in [instllation]\esProc\lib directory:
       dm.jar                       esProc computing engine and JDBC driver
       poi-3.7-20101029.jar         Process the access to the Excel file
       log4j_128.jar                Process logs
       icu4j_3_4_5.jar              Process internationalization
       dom4j-1.6.1.jar              Parse the configuration files

If esProc JDBC needs to use a database as esProc’s datasource, then the driver jar of this database needs to be put in place. Note that the demo database requires the hsqldb.jar. To realize the graphic design function in esProc JDBC, the three jars - xml-apis-ext.jar, batik-1.7.jar and batik-ext.jar – for SVG-typed image processing are needed. Make sure the esProc JDBC is a JDK1.6 version or any of the higher versions.

2) Deploy config.xml file and dfxConfig.xml file
You can find the two configuration files - config.xml and dfxConfig.xml –respectively in [installation directory]\esProc\lib and [installation directory]\esProc\classes. They need to be copied and placed under the classpath of the application project, with names remaining unchanged. Detailed information about the two files will be discussed in the second section – Configuring config.xml, and the third section – Configuring dfxConfig.xml.

3) Deploy dfx file
Place the necessary dfx file in either the application project’s classpath or the searching path specified by config.xml’s <paths/> node, or the main path specified by <mainPath/>.

4) Invoke esProc JDBC in Java
About the method of invoking a dfx file in Java and of executing the code directly, please refer to esProc Integration & Application: JavaInvocation.

2Configuring config.xml 

config.xml file contains configuration information, including license information, esProc’s main path, dfx file’s searching path, and etc. They are as follows:
<?xml version="1.0" encoding=" UTF-8"?>
< Config Version="1">
         <!—esProc register code; leave it blank for a free version -->
         < regCode>W2r@7-8cLMJ-GVU33-BhTIB3E</regCode>
         <!-- esProc charset-->
           <charSet>ISO-8859-1</charSet>
           <!--
Configure dfx file’s searching path, which is an absolute path. Multiple paths, separated by "semicolon(s)", are allowed. The dfx file can also be placed in the application project’s classpath, which has the priority over the searching path for loading the file.
           -->
           <dfxPathList>
                    < dfxPath>D:\files\dfx;D:\files\txt;D:\files</dfxPath>
           </dfxPathList>
         <!-- Date, time and other data types -->
           <dateFormat>MM/dd/yyyy</dateFormat>
           <timeFormat>HH:mm:ss</timeFormat>
           <dateTimeFormat>MM/dd/yyyy HH:mm:ss</dateTimeFormat>
           <!-- The first method for datasource configuration: configure connection pool in the application server and specify the datasource name -->
           <DBList>
                    <!-- Datasource name must be the same as that in the dfx file -->
                    <DB name="demo">
                             <property name="url" value="jdbc:hsqldb:hsql://127.0.0.1/demo"/>
                             <property name="driver" value="org.hsqldb.jdbcDriver"/>
                             <property name="type" value="HSQL"/>
                             <property name="user" value="sa"/>
                             <property name="password" value=""/>
                             <property name="batchSize" value="1000"/>
                              <!--
                             Automatically connect or not. If the value is true, use db.query() function or SQL statements starting with $ directly to access the database; if it is false, there is no automatic connection; you should first establish the connection with connect(db) statement before using the function or the statements.
                             -->
                             <property name="autoConnect" value="true"/>
                             <property name="useSchema" value="false"/>
                             <property name="addTilde" value="false"/>
                    </DB>
             <DB name="hsql">
                   <property name="url" value="jdbc:hsqldb:hsql://localhost/demo"/>
                   <property name="driver" value="org.hsqldb.jdbcDriver"/>
                   <property name="type" value="HSQL"/>
                   <property name="user" value="sa"/>
                   <property name="password"/>
                             <property name="batchSize" value="0"/>
                   <property name="autoConnect" value="false"/>
                   <property name="useSchema" value="false"/>
                   <property name="addTilde" value="false"/>
             </DB>
           </DBList >
         <!-- esProc main path, which is a single absolute path -->
           <mainPath> D:\files</mainPath>
         <!-- The save path for temporary files; it can be an absolute path. If using a relative path, put it under the main path -->
           <tempPath>\temp</tempPath>
           <bufSize>65536</bufSize>
           <localHost>192.168.0.86</localHost>
           <localPort>8282</localPort>
    <logLevel>DEBUG</logLevel>
    <callxParallel>4</callxParallel>
    <nodeParallel>4</nodeParallel>
</Config>
The config.xml file is shared by esProc JDBC and the Integration Development Environment (IDE), so the above information can be configured on the IDE interface.


First, to set the registration code, click the menu bar’s Help->Registration on the IDE interface to enter or query the registration code. Leave the registration code blank for a free version esProc. After the registration code is entered, you can click on Scan button to see the license information. Then click Register to complete the registration procedure:

Click Tool->Options on the menu bar to edit main configuration information. The key information related to JDBC, like paths, format of date and time and so on, can be edited on the Environment page: 

General page also provides JDBC-related settings, such as log level and number of parallel tasks: 

Besides, datasource information of the config.xml file can be configured in the datasource manager. Click Tool->Datasource connection on the menu bar to open the datasource manager window: 

You can add, delete or modify the datasource configuration information in the datasource manager. Click Edit to edit the connection parameter of the datasource: 
In the datasource manager, you can set the information about the driver used by the datasource, datasource URL, user name, password, batch size, and etc. Note that demo is the system datasource, whose connection URL cannot be changed. In addition, esProc JDBC itself cannot be used as a datasource during the datasource connection configuration.

config.xml file will be loaded automatically in Java application’s classpath for use of esProc JDBC and cannot be renamed at this point. However, if esProc JDBC’s connecting string uses this format (...?config=...), the .xml file specified by config in the connecting string will be loaded for use in the configuration and the file defined in the default configuration will be ignored.

For example, based on a connecting string like con= DriverManager.getConnection("jdbc:esproc:local:/?config=myconfig.xml"), the configuration in myconfig.xml will be used.

3Configuring dfxConfig.xml 

The dfxConfig.xml file has the configuration information about concurrency, log property, connection pool, and so on. Take the following file as an example:
<dfxConfig>
           <!--
           Maximum amount of concurrency. Set the allowed max. number of concurrent tasks; tasks performed in parallel within the same connection are handled as the concurrent ones. The number should be within the licensing limit.
            -->
           <maxConcurrents>10</maxConcurrents>
           <!--
           Maximum wait time. If the number of concurrent tasks exceeds the maximum amount of concurrency, the extra tasks will be in wait state. Exceptions will be thrown if the wait time exceeds its specified limit.
           -->
           < maxWaitTime>5000</maxWaitTime>
           <!-- Files of log configuration property -->
           < log>logger.properties</log>
           <!-- Configure connection pool in the application server and specify the datasource name -->
           <jndi-ds-configs>
                    <!—jndi is a prefix -->
                    <jndi-prefix>java:comp/env</jndi-prefix>
                    <!-- Datasource name must be the same as that in the dfx file -->
                   <jndi-ds-config>
                              <name>olap</name>
                            <dbType>ACCESS</dbType>
                            <dbCharset>ISO-8859-1</dbCharset>
                            <clientCharset>ISO-8859-1</clientCharset>
                              <needTranContent>false</needTranContent>
                              <needTranSentence>false</needTranSentence>
                              <!--
                             Automatically connect or not. If the value is true, use db.query() function directly to access the database; if it is false, there is no automatic connection; you should first establish the connection with connect(db) statement before using the function.
                             -->
                             <autoConnect>true</autoConnect>
                    </jndi-ds-config>
           </jndi-ds-configs>
</dfxConfig>

If a datasource connection needs to be established in the dfx file invoked within the esProc JDBC, the related information should be edited in config.xml’s datasource configuration or dfxConfig.xml’s connection pool configuration. A point worth particular note is that, if db.query() function or $(db) sql accesses the database directly, the property of autoConnect of this database should be true. For the usage of esProc JDBC, please refer to esProcIntegration & Application: Java Invocation

No comments:

Post a Comment