JDBC 데이터소스 구성 예제

본 부록에서는 주요 DB 벤더들에 대한 데이터소스 설정 예제를 제공한다.

1. 개요

본 부록에서 설정 예제를 제공하는 JDBC 데이터소스는 다음과 같다.

  • Oracle Thin

  • Oracle OCI

  • DB2 Type4(JCC)

  • DB2 Type2(JCC)

  • Sybase jConnect 5.x, 6.x

  • MSSQL 2005 Type4

  • Informix Type4

  • Tibero Type4

  • MySQL 5.x Type4

본 부록을 참고하여 데이터소스 설정을 할 수 있다. 데이터소스를 설정하는 방법에 대한 자세한 내용은 데이터소스 설정을 참고한다.

2. Oracle Thin(Type4) 구성 예제

2.1. Oracle Thin Connection Pool 데이터소스

다음은 Oracle Thin Connection Pool 데이터소스를 구성한 예이다.

Oracle Thin Connection Pool 데이터소스 : <domain.xml>
<domain>
    . . .
    <resources>
        <data-source>
            <database>
                <data-source-id>ora_thin_cpds</data-source-id>
                <export-name>ora_thin_cpds</export-name>
                <data-source-class-name>
                    oracle.jdbc.pool.OracleConnectionPoolDataSource
                </data-source-class-name>
                <data-source-type>
                    ConnectionPoolDataSource
                </data-source-type>
                <vendor>oracle</vendor>
                <server-name>192.168.1.2</server-name>
                <port-number>1521</port-number>
                <database-name>orcl</database-name>
                <user>scott</user>
                <password>tiger</password>
                <property>
                    <name>driverType</name>
                    <type>java.lang.String</type>
                    <value>thin</value>
                </property>
                <connection-pool>
                    . . .
                </connection-pool>
            </database>
        . . .
        </data-source>
    . . .
    </resources>
</domain>

2.2. Oracle Thin XA 데이터소스

다음은 Oracle Thin XA 데이터소스를 구성한 예이다.

Oracle Thin XA 데이터소스 : <domain.xml>
<domain>
    . . .
    <resources>
        <data-source>
            <database>
                <data-source-id>ora_thin_xads</data-source-id>
                <export-name>ora_thin_xads</export-name>
                <data-source-class-name>
                    oracle.jdbc.xa.client.OracleXADataSource
                </data-source-class-name>
                <data-source-type>
                    XADataSource
                </data-source-type>
                <vendor>oracle</vendor>
                <server-name>192.168.1.2</server-name>
                <port-number>1521</port-number>
                <database-name>orcl</database-name>
                <user>scott</user>
                <password>tiger</password>
                <property>
                    <name>driverType</name>
                    <type>java.lang.String</type>
                    <value>thin</value>
                </property>
                <connection-pool>
                    . . .
                </connection-pool>
            </database>
        . . .
        </data-source>
    . . .
    </resources>
</domain>

2.3. java.util.Properties 설정 예제 with Oracle ASO

Oracle ASO 설정 예제를 이용해서 java.util.Properties 설정 방법에 대해 설명한다.

<property>를 사용하고, 기본 형식은 <type>은 java.util.Properties, <value>는 다음의 형식으로 입력한다.

 [프로퍼티 이름 1]=[값 1], [프로퍼티 이름 2]=[값 2]
java.util.Properties 설정 예제 with Oracle ASO : <domain.xml>
<domain>
    . . .
    <resources>
        <data-source>
            <database>
                <data-source-id>oracle_CPDS1</data-source-id>
                <export-name>oracle_CPDS1</export-name>
                <data-source-class-name>
                    oracle.jdbc.pool.OracleConnectionPoolDataSource
                </data-source-class-name>
                <data-source-type>
                    ConnectionPoolDataSource
                </data-source-type>
                <vendor>oracle</vendor>
                <server-name>192.168.1.2</server-name>
                <port-number>1521</port-number>
                <database-name>ora9</database-name>
                <user>scott</user>
                <password>tiger</password>
                <property>
                    <name>driverType</name>
                    <type>java.lang.String</type>
                    <value>thin</value>
                </property>
                <property>
                    <name>ConnectionProperties</name>
                    <type>java.util.Properties</type>
                    <value>
                        oracle.net.encryption_client=xxxx,
                        oracle.net.encryption_types_client=(3DES168,3DES112),
                        oracle.net.crypto_checksum_client=xxxx,
                        oracle.net.crypto_checksum_types_client=(MD5)
                    </value>
                </property>
                <connection-pool>
                    . . .
                </connection-pool>
            </database>
        . . .
        </data-source>
    . . .
    </resources>
</domain>

3. Oracle OCI (Type2) 구성 예제

3.1. Oracle OCI Connection Pool 데이터소스

Oracle OCI 드라이버를 사용하기 위해서는 선행 작업이 필요한데, JEUS를 실행할 때 -Djava.library.path로 Oracle OCI 드라이버의 네이티브 라이브러리 경로를 설정해야 한다.

Oracle OCI Connection Pool 데이터소스 : <domain.xml>
<domain>
    . . .
    <resources>
        <data-source>
            <database>
                <data-source-id>ora_oci_cpds</data-source-id>
                <export-name>ora_oci_cpds</export-name>
                <data-source-class-name>
                    oracle.jdbc.pool.OracleConnectionPoolDataSource
                </data-source-class-name>
                <data-source-type>
                    ConnectionPoolDataSource
                </data-source-type>
                <vendor>oracle</vendor>
                <server-name>192.168.1.2</server-name>
                <port-number>1521</port-number>
                <database-name>ora9</database-name>
                <user>scott</user>
                <password>tiger</password>
                <property>
                    <name>driverType</name>
                    <type>java.lang.String</type>
                    <value>oci</value>
                </property>
                <property>
                    <name>TNSEntryName</name>
                    <type>java.lang.String</type>
                    <value>ORCL</value>
                </property>
                <connection-pool>
                    . . .
                </connection-pool>
            </database>
        . . .
        </data-source>
    . . .
    </resources>
</domain>

4. DB2 구성 예제

4.1. DB2 Type4(JCC) Connection Pool 데이터소스

다음은 DB2 Type4 Connection Pool 데이터소스를 구성한 예이다.

DB2 Type4(JCC) Connection Pool 데이터소스 : <domain.xml>
<domain>
    . . .
    <resources>
        <data-source>
            <database>
                <data-source-id>db2_type4_cpsd</data-source-id>
                <export-name>db2_type4_cpds</export-name>
                <data-source-class-name>
                    com.ibm.db2.jcc.DB2ConnectionPoolDataSource
                </data-source-class-name>
                <data-source-type>
                    ConnectionPoolDataSource
                </data-source-type>
                <vendor>db2</vendor>
                <server-name>192.168.1.1</server-name>
                <port-number>50000</port-number>
                <database-name>TEST1</database-name>
                <user>db2inst1</user>
                <password>password</password>
                <property>
                    <name>driverType</name>
                    <type>java.lang.Integer</type>
                    <value>4</value>
                </property>
                <connection-pool>
                    . . .
                </connection-pool>
            </database>
        . . .
        </data-source>
    . . .
    </resources>
</domain>

4.2. DB2 Type4(JCC) XA 데이터소스

다음은 DB2 Type4 XA 데이터소스를 구성한 에이다.

DB2 Type4(JCC) XA 데이터소스 : <domain.xml>
<domain>
    . . .
    <resources>
        <data-source>
            <database>
                <data-source-id>db2_type2_cpsd</data-source-id>
                <export-name>db2_type2_cpds</export-name>
                <data-source-class-name>
                    com.ibm.db2.jdbc.DB2XADataSource
                </data-source-class-name>
                <data-source-type>
                    XADataSource
                </data-source-type>
                <vendor>db2</vendor>
                <server-name>192.168.1.1</server-name>
                <port-number>50000</port-number>
                <database-name>TEST1</database-name>
                <user>db2inst1</user>
                <password>password</password>
                <connection-pool>
                    . . .
                </connection-pool>
            </database>
        . . .
        </data-source>
    . . .
    </resources>
</domain>

4.3. DB2 Type2(JCC) XA 데이터소스

DB2 Type 2 드라이버를 사용하기 위해서는 DB2 클라이언트를 설치하여 DB Alias를 설정한 뒤 JEUS를 실행할 때 -Djava.library.path 또는 시스템의 라이브러리 경로에 DB2 클라이언트의 네이티브 라이브러리 경로를 설정해야 한다. 다음의 예제에서 Database Name이 DB Alias가 되고 DB2 서버 주소와 포트 번호는 입력할 필요가 없다.

B2 Type2(JCC) XA 데이터소스 : <domain.xml>
<domain>
    . . .
    <resources>
        <data-source>
            <database>
                <data-source-id>db2_type2_xads</data-source-id>
                <export-name>db2_type2_xads</export-name>
                <data-source-class-name>
                    com.ibm.db2.jdbc.DB2XADataSource
                </data-source-class-name>
                <data-source-type>
                    XADataSource
                </data-source-type>
                <vendor>db2</vendor>
                <server-name>192.168.1.1</server-name>
                <port-number>50000</port-number>
                <database-name>TEST1</database-name>
                <user>db2inst1</user>
                <password>password</password>
                <connection-pool>
                    . . .
                </connection-pool>
            </database>
        . . .
        </data-source>
    . . .
    </resources>
</domain>

5. Sybase 구성 예제

5.1. Sybase jConnect 5.x Connection Pool 데이터소스

다음은 Sybase jConnect 5.x Connection Pool 데이터소스를 구성한 예이다.

Sybase jConnect 5.x Connection Pool 데이터소스 : <domain.xml>
<domain>
    . . .
    <resources>
        <data-source>
            <database>
                <data-source-id>syb_jconn5_cpds</data-source-id>
                <export-name>syb_jconn5_cpds</export-name>
                <data-source-class-name>
                    com.sybase.jdbc2.jdbc.SybConnectionPoolDataSource
                </data-source-class-name>
                <data-source-type>
                    ConnectionPoolDataSource
                </data-source-type>
                <vendor>sybase</vendor>
                <server-name>192.168.1.1</server-name>
                <port-number>5000</port-number>
                <database-name>testdb</database-name>
                <user>sa</user>
                <password>password</password>
                <property>
                    <name>networkProtocol</name>
                    <type>java.lang.String</type>
                    <value>Tds</value>
                </property>
                <connection-pool>
                    . . .
                </connection-pool>
            </database>
        . . .
        </data-source>
    . . .
    </resources>
</domain>

5.2. Sybase jConnect 6.x XA 데이터소스

다음은 Sybase jConnect 6.x XA 데이터소스를 구성한 예이다.

Sybase jConnect 6.x XA 데이터소스 : <domain.xml>
<domain>
    . . .
    <resources>
        <data-source>
            <database>
                <data-source-id>syb_jconn6_xads</data-source-id>
                <export-name>syb_jconn6_xads</export-name>
                <data-source-class-name>
                    com.sybase.jdbc2.jdbc.SybConnectionPoolDataSource
                </data-source-class-name>
                <data-source-type>
                    ConnectionPoolDataSource
                </data-source-type>
                <vendor>sybase</vendor>
                <server-name>192.168.1.1</server-name>
                <port-number>5000</port-number>
                <database-name>testdb</database-name>
                <user>sa</user>
                <password>password</password>
                <property>
                    <name>networkProtocol</name>
                    <type>java.lang.String</type>
                    <value>Tds</value>
                </property>
                <connection-pool>
                    . . .
                </connection-pool>
            </database>
        . . .
        </data-source>
    . . .
    </resources>
</domain>

6. MSSQL 구성 예제

6.1. MSSQL 2005 Connection Pool 데이터소스

다음은 MSSQL 2005 Connection Pool을 구성한 예이다.

MSSQL 2005 Connection Pool 데이터소스 : <domain.xml>
<domain>
    . . .
    <resources>
        <data-source>
            <database>
                <data-source-id>mssql_2005_cpds</data-source-id>
                <export-name>mssql_2005_cpds</export-name>
                <data-source-class-name>
                    com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolDataSource
                </data-source-class-name>
                <data-source-type>
                    ConnectionPoolDataSource
                </data-source-type>
                <vendor>mssql</vendor>
                <server-name>192.168.1.1</server-name>
                <port-number>1411</port-number>
                <database-name>testdb</database-name>
                <user>jeusdb1</user>
                <password>password</password>
                <connection-pool>
                    . . .
                </connection-pool>
            </database>
        . . .
        </data-source>
    . . .
    </resources>
</domain>

ODBC 설정은 JDBC보다 먼저 설정되어야 한다.

7. Informix 구성 예제

7.1. Informix Connection Pool 데이터소스

다음은 Informix Connection Pool 데이터소스를 구성한 예이다.

Informix Connection Pool 데이터소스 : <domain.xml>
<domain>
    . . .
    <resources>
        <data-source>
            <database>
                <data-source-id>infomix_cpds</data-source-id>
                <export-name>infomix_cpds</export-name>
                <data-source-class-name>
                    com.informix.jdbcx.IfxConnectionPoolDataSource
                </data-source-class-name>
                <data-source-type>
                    ConnectionPoolDataSource
                </data-source-type>
                <vendor>informix</vendor>
                <server-name>192.168.1.1</server-name>
                <port-number>2002</port-number>
                <database-name>skynps</database-name>
                <user>informix</user>
                <password>password</password>
                <property>
                    <name>IfxIFXHOST</name>
                    <type>java.lang.String</type>
                    <value>192.168.1.43</value>
                </property>
                <connection-pool>
                    . . .
                </connection-pool>
            </database>
        . . .
        </data-source>
    . . .
    </resources>
</domain>

8. Tibero 구성 예제

8.1. Tibero Connection Pool 데이터소스

다음은 Tibero Connection Pool 데이터소스를 구성한 예이다.

Tibero Connection Pool 데이터소스 : <domain.xml>
<domain>
    . . .
    <resources>
        <data-source>
            <database>
                <data-source-id>tibero_cpds</data-source-id>
                <export-name>tibero_cpds</export-name>
                <data-source-class-name>
                    com.tmax.tibero.jdbc.ext.TbConnectionPoolDataSource
                </data-source-class-name>
                <data-source-type>
                    ConnectionPoolDataSource
                </data-source-type>
                <vendor>tibero</vendor>
                <server-name>192.168.1.1</server-name>
                <port-number>8629</port-number>
                <database-name>testdb</database-name>
                <user>jeusdb1</user>
                <password>password</password>
                <property>
                    <name>driverType</name>
                    <type>java.lang.String</type>
                    <value>thin</value>
                </property>
                <connection-pool>
                    . . .
                </connection-pool>
            </database>
        . . .
        </data-source>
    . . .
    </resources>
</domain>

9. MySQL 5.x 구성 예제

9.1. MySQL Connector/J Connection Pool 데이터소스

다음은 MySQL Connector/J Connection Pool 데이터소스를 구성한 예이다.

MySQL Connector/J Connection Pool 데이터소스 : <domain.xml>
<domain>
    . . .
    <resources>
        <data-source>
            <database>
                <data-source-id>mysql_cpds</data-source-id>
                <export-name>mysql_cpds</export-name>
                <data-source-class-name>
                  com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
                </data-source-class-name>
                <data-source-type>
                    ConnectionPoolDataSource
                </data-source-type>
                <vendor>mysql</vendor>
                <server-name>192.168.1.1</server-name>
                <port-number>3306</port-number>
                <database-name>testdb</database-name>
                <user>tester</user>
                <password>password</password>
                <connection-pool>
                    . . .
                </connection-pool>
            </database>
        . . .
        </data-source>
    . . .
    </resources>
</domain>