Connection Pool
Connection Pool#
다음의 방법으로 연결 풀 (Connection Pool)을 설정하고 관리할 수 있다.
- AltibaseConnectionPoolDataSource 사용 WAS에서 연결 풀을 사용할 때, 이 클래스를 WAS의 JDBC연결 풀 설정에서 지정한다. 6.3.1 버전 이하의 Altibase JDBC 드라이버에서 이 클래스의 이름은 ABConnectionPoolDataSource였다.
 
AltibaseConnectionPoolDataSource에서 설정하는 속성 정보는 아래와 같다.
| 프로퍼티 이름 | 설명 | 
|---|---|
| databaseName | 데이터베이스 이름 | 
| dataSourceName | dataSource 이름 | 
| loginTimeout | 데이터베이스 로그인을 위한 최대 대기 시간 | 
| logWriter | dataSource를 위한 Log writer | 
| password | 데이터베이스 패스워드 | 
| portNumber | 데이터베이스 포트 넘버 | 
| serverName | 데이터베이스 서버명 | 
| URL | Altibase 연결을 위한 Connection string 정보 (대문자 주의) | 
| user | 데이터베이스 사용자 ID | 
WAS (Web Application Server) 설정#
Altibase는 아래의 웹 애플리케이션 서버와 함께 사용할 수 있다.
- 
Tomcat 8.x
- 
Code example
Context initContext = new InitialContext(); Context envContext = (Context)initContext.lookup("java:/comp/env"); DataSource ds = (DataSource)envContext.lookup("jdbc/altihdb"); Connection conn = ds.getConnection(); // ... 
 - 
 - 
WebLogic 12.x
 - 
Jeus 6.x
 
웹 애플리케이션 서버에서 JDBC 드라이버와 연결 풀을 설정하고 사용하는 방법에 대해서는 각각의 제품별 매뉴얼을 참조하기 바란다.
Tomcat 8.x#
Apache Tomcat의 설치 및 설정 방법에 대한 자세한 내용은 http://tomcat.apache.org/tomcat-8.0-doc/index.html를 참조하기 바란다.
Context configuration#
아래와 같이 Context에 JNDI DataSource를 추가한다.
<Context>
 <Resource name="jdbc/altihdb" auth="Container" type="javax.sql.DataSource"
 driverClassName="Altibase.jdbc.driver.AltibaseDriver"
 url="jdbc:Altibase://localhost:20300/mydb" 
 username="SYS" password="MANAGER" 
 maxTotal="100" maxIdle="30" maxWaitMillis="10000" />
 </Context>
web.xml configuration#
<!----- web.xml ----->
<resource-ref>
 <description>Altibase Datasource example</description>
 <res-ref-name>jdbc/altihdb</res-ref-name>
 <res-type>javax.sql.DataSource</res-type>
 <res-auth>Container</res-auth>
</resource-ref>
Code example#
Context initContext = new InitialContext();
Context envContext  = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/altihdb");
Connection conn = ds.getConnection();
// ...
WebLogic 12.x#
WebLogic Server의 설치 및 설정 방법에 대한 자세한 내용은 Oracle WebLogic Server 페이지를 참조하기 바란다.
아래의 링크를 참조하여 JDBC datasource와 Connection Pool을 설정할 수 있다.
Altibase를 위한 설정 옵션은 아래와 같다.
- 데이터베이스 유형(Database Type): 기타(Other)
 - 드라이버 클래스 이름(Driver Class Name): Altibase.jdbc.driver.AltibaseDriver
 - URL: jdbc:Altibase://localhost:20300/mydb
 
Jeus 6.x#
$JEUS_HOME/config/JeusMain.xml 파일의 <data-source> 요소를 편집하여 연결 풀을 설정한다.
<!------ JeusMain.xml ----->
<resource>
    <data-source>
        <database>
            <vendor>others</vendor>
            <export-name>jdbc/altihdb</export-name>
            <data-source-class-name>
                Altibase.jdbc.driver.AltibaseConnectionPoolDataSource
            </data-source-class-name>
            <data-source-type>ConnectionPoolDataSource</data-source-type>
            <auto-commit>true</auto-commit>
            <property>
                <name>PortNumber</name>
                <type>java.lang.Integer</type>
                <value>20300</value>
            </property>
            <property>
                <name>Password</name>
                <type>java.lang.String</type>
                <value>MANAGER</value>
            </property>
            <property>
                <name>ServerName</name>
                <type>java.lang.String</type>
                <value>localhost</value>
            </property>
            <property>
                <name>ConnectionAttributes</name>
                <type>java.lang.String</type>
                <value>;create=true</value>
            </property>
            <property>
                <name>DatabaseName</name>
                <type>java.lang.String</type>
                <value>mydb</value>
            </property>
            <property>
                <name>User</name>
                <type>java.lang.String</type>
                <value>SYS</value>
            </property>
        </database>
    </data-source>
</resource>
연결 확인#
Altibase JDBC 드라이버는 연결 유효성 검사를 위해, 일반 쿼리보다 가볍게 실행되는 핑(PING) 방식의 쿼리를 지원한다. WAS에서 poolPingQuery 또는 validationQuery 등으로 이용할 수 있다.
쿼리 패턴은 아래와 같으며, PreparedStatment에서도 사용할 수 있다.
- 
허용되는 패턴
/* PING */ SELECT 1 /* ping */ select 1 /* PING */ SELECT 1 /* PING */ select 1 /* PING */ select 1 /* PING */ select 1 /* PING */ seLECt 1 /* ping */ SELECT 1 - 
허용되지 않는 패턴
/* PING */SELECT 1 /*+ ping */ select 1 /*ping */ select 1 /* ping */ select 1 from dual /** PING */ SELECT 1 //* PING */ SELECT 1