달력

4

« 2024/4 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
2006. 10. 30. 19:47

iBATIS 2.0 Developer's Guide 정리 2 프레임워크2006. 10. 30. 19:47

4. Result Maps
   4.1 Implicit Result Maps
   4.2 Primitive Results(i.e. String, Integer, Boolean)
   4.3 Map Results
   4.4 Complex Properties(i.e. a property of a class defined by the user)
   4.5 Avoiding N+1 Selects (1:1)
   4.6 Complex Collection Properties(i.e. a property of a class defined by the user)
   4.7 Avoiding N+1 Selects (1:M and M:N)
   4.8 Complex Collection Properties
   4.9 Avoiding N+1 Selects(1:M and M:N)
   4.10 Composite Keys or Multiple Complex Parameters Properties
5. Supported Types for Parameter Maps and Result Maps
6. Caching Mapped Statement Results
   6.1 Read-Only vs Read/Write
   6.2 Serializable Read/Write Caches
   6.3 Cache Types
7. Dynamic Mapped Statements
   7.1 Binary Conditional Elements
   7.2 Unary Conditional Elements
   7.3 Other Elements
8. Simple Dynamic SQL Elements
9. Programming with Data Mapper: The API
   9.1 Configuration
   9.2 Transactions
   9.3 Batches
   9.4 Executing Statements via the SqlMapClient API
10. Logging SqlMap Activity with Jakarta Commons Logging
11. The One Page JavaBeans Course
12. Resources (comibatiscommonresources*)
13. SimpleDataSource (comibatiscommonjdbc*)

4.1 Implicit Result Maps

재사용이 필요 없는 경우 명시적으로 resultMap을 선언하지 않고도 원하는 결과를 얻을 수 있다.

<statement id="getProduct" resultClass="com.ibatis.example.Product">
   select
   PRD_ID as id,
   PRD_DESCRIPTION as description
   from PRODUCT
   where PRD_ID = #value#
</statement>

위의 예에서 resultClass를 정의하고 자바 빈의 프로퍼티와 맵칭되는 alias를 사용했다. 이러한 경우 resultMap이 없어도 된다.

명시적인 resultMap의 사용과 위와 같은 묵시적 result map 간에는 tradeoff가 존재한다. 묵시적인 result map 사용시 column type, null value를 명시할 수 없다. 또 resultClass를 통한 자동 맵핑 사용시 성능 오버헤드가 따른다.

4.2 Primitive Results(i.e. String, Integer, Boolean)

primitive type은 오직 하나의 프로퍼티만 가질 수 있다. 그리고 그 프로퍼티의 이름은 임의로 정의할 수 있다.

<resultMap id="get-product-result" class="java.lang.String">
   <result property="value" column="PRD_DESCRIPTION"/>
</resultMap>

위의 예보다 간단한 방법은 mapped statement에서 아래와 같이 resultClass를 사용하는 방법이다(이때 as를 사용하여 value라는 컬럼 alias를 사용한 점에 유의하기 바란다).

<statement id="getProductCount" resultClass="java.lang.Integer">
   select count(1) as value
   from PRODUCT
</statement>

4.3 Map Results

Result map은 HashMap, TreeMap과 같은 Map 인스턴스 쉽게 채울 수 있다. 이러한 객체들의 collection(Lis of Map 등)도 API(executeQueryForList 등)를 사용하여 검색할 수 있다.

<resultMap id="get-product-result" class="java.util.HashMap">
   <result property="id" column="PRD_ID"/>
   <result property="code" column="PRD_CODE"/>
   <result property="description" column="PRD_DESCRIPTION"/>
   <result property="suggestedPrice" column="PRD_SUGGESTED_PRICE"/>
</resultMap>

또 아래와 같이 Map 타입에 대한 묵시적 result map을 사용할 수도 있다.

<statement id="getProductCount" resultClass="java.util.HashMap">
   select * from PRODUCT
</statement>

4.4 Complex Properties(i.e. a property of a class defined by the user)

<resultMap id="get-product-result" class="com.ibatis.example.Product">
   <result property="id" column="PRD_ID"/>
   <result property="description" column="PRD_DESCRIPTION"/>
  <result property="category" column="PRD_CAT_ID" select="getCategory"/>
</resultMap>

<resultMap id="get-category-result" class="com.ibatis.example.Category">
   <result property="id" column="CAT_ID"/>
   <result property="description" column="CAT_DESCRIPTION"/>
</resultMap>

<statement id="getProduct" parameterClass="int" resultMap="get-product-result">
   select * from PRODUCT where PRD_ID = #value#
</statement>

<statement id="getCategory" parameterClass="int" resultMap="get-category-result">
   select * from CATEGORY where CAT_ID = #value#
</statement>

4.5 Avoiding N+1 Selects (1:1)

4.4와 같은 방법 사용시 N+1 Select 문제(Product을 읽기 위해 1번, CATEGORY를 읽기 위해 N개의 Product에 대해 N번 읽기)가 발생한다.

이러한 문제를 해결하기 위해 JOIN을 사용한다.

<resultMap id="get-product-result" class="com.ibatis.example.Product">
   <result property="id" column="PRD_ID"/>
   <result property="description" column="PRD_DESCRIPTION"/>
   <result property="category.id" column="CAT_ID" />
   <result property="category.description" column="CAT_DESCRIPTION" />

</resultMap>

<statement id="getProduct" parameterClass="int" resultMap="get-product-result">
   select *
   from PRODUCT, CATEGORY
   where PRD_CAT_ID=CAT_ID
   and PRD_ID = #value#
</statement>

4.6 Complex Collection Properties(i.e. a property of a class defined by the user)

<resultMap id="get-category-result" class="com.ibatis.example.Category">
   <result property="id" column="CAT_ID"/>
   <result property="description" column="CAT_DESCRIPTION"/>
   <result property="productList" column="CAT_ID" select=" getProductsByCatId"/>
</resultMap>

<resultMap id="get-product-result" class="com.ibatis.example.Product">
   <result property="id" column="PRD_ID"/>
   <result property="description" column="PRD_DESCRIPTION"/>
</resultMap>

<statement id="getCategory" parameterClass="int" resultMap="get-category-result">
   select * from CATEGORY where CAT_ID = #value#
</statement>

<statement id="getProductsByCatId" parameterClass="int" resultMap="get-product-result">
   select * from PRODUCT where PRD_CAT_ID = #value#
</statement>

4.7 Avoiding N+1 Selects (1:M and M:N)

4.6의 방법은 Product을 로딩할 때 마다 2개의 SQL 문장(Product을 위한 SQL 문장과 CATEGORY를 위한 문장)이 수행된다는 문제를 갖는다. 따라서 N+1 문제를 동일하게 갖는다.

이 문제를 해결하기 위해 JOIN과 NESTED PROPERTY MAPPING을 사용한다.

<resultMap id="get-product-result" class="com.ibatis.example.Product">
   <result property="id" column="PRD_ID"/>
   <result property="description" column="PRD_DESCRIPTION"/>
   <result property="category.id" column="CAT_ID" />
   <result property="category.description" column="CAT_DESCRIPTION" />

</resultMap>

<statement id="getProduct" parameterClass="int" resultMap="get-product-result">
   select *
   from PRODUCT, CATEGORY
   where PRD_CAT_ID=CAT_ID
   and PRD_ID = #value#
</statement>

JOIN을 사용하는 것이 항상 좋은 것은 아니다. JOIN으로 얻어 온 정보를 사용하지 않을 경우에는 JOIN 대신 lazy-loading을 적용하여 sub-select를 사용하는 것이 좋다.

4.8 Complex Collection Properties

<resultMap id="get-category-result" class="com.ibatis.example.Category">
   <result property="id" column="CAT_ID"/>
   <result property="description" column="CAT_DESCRIPTION"/>
   <result property="productList" column="CAT_ID" select=" getProductsByCatId"/>
</resultMap>

<resultMap id="get-product-result" class="com.ibatis.example.Product">
   <result property="id" column="PRD_ID"/>
   <result property="description" column="PRD_DESCRIPTION"/>
</resultMap>

<statement id="getCategory" parameterClass="int" resultMap="get-category-result">
   select * from CATEGORY where CAT_ID = #value#
</statement>

<statement id="getProductsByCatId" parameterClass="int" resultMap="get-product-result">
   select * from PRODUCT where PRD_CAT_ID = #value#
</statement>

4.9 Avoiding N+1 Selects(1:M and M:N)

<sqlMap namespace="Calendar">
   <resultMap id="quarterMap" class="calendarQuarter" groupBy="quarter">
       <result property="quarter" column="quarter"/>
       <result property="name" column="name"/>
       <result property="description" column="description"/>
       <result property="months" resultMap="Calendar.monthMap"/>
   </resultMap>

   <resultMap id="monthMap" class="calendarMonth">
       <result property="name" column="monthName"/>
       <result property="description" column="monthDescription"/>
       <result property="broadcastStartDate" column="broadcastStartDate"/>
       <result property="broadcastEndDate" column="broadcastEndDate"/>
   </resultMap>

   <select id="getQuartersForServiceYear" resultMap="quarterMap">
       select distinct
       QuarterNumber as quarter,
       QuarterName as name,
       QuarterDesc as description,
       SeasonYear as year,
       MonthName as monthName,
       MonthDesc as monthDescription,
       min(broadcastDate) as broadcastStartDate,
       max(broadcastDate) as broadcastEndDate
       from BroadcastDate
       where SeasonYear = #year#
       and MonthName is not null
       group by
       QuarterDesc,
       QuarterNumber,
       QuarterName,
       SeasonYear,
       MonthName,
       MonthDesc
       order by broadcastStartDate
   </select>
</sqlMap>

4.10 Composite Keys or Multiple Complex Parameters Properties

위의 예에서 resultMap의 column 속성에 하나의 키 값만 사용된 것을 알 수 있다. 아래 예는 관련된 mapped statement에 다수의 컬럼을 전달하는 방법을 보이고 있다.

<resultMap id="get-order-result" class="com.ibatis.example.Order">
   <result property="id" column="ORD_ID"/>
   <result property="customerId" column="ORD_CST_ID"/>
   …
   <result property="payments" column="{itemId=ORD_ID, custId=ORD_CST_ID}"
       select=" getOrderPayments"/>
</resultMap>

<statement id="getOrderPayments" resultMap="get-payment-result">
   select * from PAYMENT
   where PAY_ORD_ID = #itemId#
   and PAY_CST_ID = #custId#
</statement>

5. Supported Types for Parameter Maps and Result Maps

iBATIS 프레임워크가 parameter/result로 지원하는 자바 타입은 아래와 같다.

Java TypeJavaBean/Map
Property Mapping
Result Class /
Parameter Class***
Type Alias**
booleanYESNOboolean
java.lang.Boolean
byte
YES
YES
YES
NO
boolean
byte
java.lang.ByteYESYESbyte
short
java.lang.Short
YES
YES
NO
YES
short
short
intYESNOint/integer
java.lang.IntegerYESYESint/integer
longYESNOlong
java.lang.LongYESYESlong
floatYESNOfloat
java.lang.FloatYESYESfloat
doubleYESNOdouble
java.lang.DoubleYESYESdouble
java.lang.String
java.util.Date
YES
YES
YES
YES
string
date
java.math.BigDecimal
* java.sql.Date
YES
YES
YES
YES
decimal
N/A

* java.sql.Time
YESYESN/A
* java.sql.TimestampYESYESN/A

* The use of java.sql. date types is discouraged.

6. Caching Mapped Statement Results

statement 태그에 cacheModel을 명시함으로써 Query Mapped Statement의 결과는 캐쉬될 수 있다.

<cacheModel id="product-cache" type ="LRU" readOnly="true" serialize="false">
   <flushInterval hours="24"/>
   <flushOnExecute statement="insertProduct"/>
   <flushOnExecute statement="updateProduct"/>
   <flushOnExecute statement="deleteProduct"/>
   <property name="cache-size" value="1000" />
</cacheModel>

flushinterval에는 hours, minutes, seconds, milliseconds 등을 사용할 수 있다.

<statement id="getProductList" cacheModel="product-cache">
   select * from PRODUCT where PRD_CAT_ID = #value#
</statement>

6.1 Read-Only vs Read/Write

iBATIS는 read-only, read-write 캐쉬를 모두 지원한다. read-only 캐쉬는 사용자 간에 공유되어 눈에 뛸 만한 성능 향상을 제공한다. 하지만 read-only 캐쉬에서 얻어진 객체는 변경되어서는 안된다. 변경을 하기 위해서는 새로운 객체를 데이터베이스에서 읽어야 한다.

6.2 Serializable Read/Write Caches

6.1에서 설명한 세션별 read-write 캐쉬는 전체적인 애플리케이션의 성능 향상에는 많은 도움이 되지 않는다. 전체적인 애플리케이션의 성능에 보다 도움이 되는 캐쉬 방법으로 serializable read-write 캐쉬가 있다. serializable read-write 캐쉬는 각 세션에 캐쉬된 객체에 대한 다른 인스턴스(복사본)를 제공한다. 그래서 각 세션은 안전하게 인스턴스를 변경할 수 있다. serializable read-write 캐쉬를 사용할 때 캐쉬될 객체들은 serializable해야 한다. 이로 인해 lazy loading과 serializable read-write 캐쉬가 함께 사용되면 lazy proxy가 serializable하지 않기 때문에 문제가 발생한다. 따라서 serializable read-write 캐쉬를 사용할 경우 lazy load 기능을 사용하지 말아야 한다.

6.3 Cache Types

CacheController 인터페이스를 지원하는 여러가지 캐쉬가 존재한다.

"Memory"(com.ibatis.db.sqlmap.cache.memory.MemoryCacheController)

캐쉬의 행위를 관리하기 위해 reference type을 사용한다. GC가 캐쉬에 남아 있어야 하는지 여부를 효과적으로 판단한다. 객체 재사용의 패턴이 인식 불가하거나 메모리가 부족한 경우 적합한 방법이다.

<cacheModel id="product-cache" type="MEMORY">
   <flushInterval hours="24"/>
   <flushOnExecute statement="insertProduct"/>
   <flushOnExecute statement="updateProduct"/>
   <flushOnExecute statement="deleteProduct"/>
   <property name="reference-type" value="WEAK" />
</cacheModel>

reference type은 아래와 같은 값을 가질 수 있다.

WEAK(default)

대부분의 경우에 적합한 방법

자주 참조된는 결과에는 우수한 성능을 제공하지만 다른 객체를 위해 메모리를 할당하기 위해 메모리가 더 이상 사용되지 않는다고 가정하고 메모리를 릴리즈한다.

SOFT결과가 현재 사용되지 않고 있고 다른 객체에 의해 필요한 경우 메모리가 부족한 경우를 최소화한다.
STRONG

캐쉬가 명시적으로 flush되기 전에는 메모리에 유지한다. 다음과 같은 경우에 이상적이다.

1. 메모리가 아주 적게 사용된다.

2. 상대적으로 정적인 경우

3. 아주 자주 사용된다.

위와 같은 경우 성능 향상에 크게 도움이 된다. 하지만 메모리 부족이 발생할 수 있다.

"LRU"(com.ibatis.db.sqlmap.cache.lru.LruCacheController)

객체를 캐쉬에서 자동으로 제거하기 위해 LRU 알고리즘을 사용한다.

<cacheModel id="product-cache" type="LRU">
   <flushInterval hours="24"/>
   <flushOnExecute statement="insertProduct"/>
   <flushOnExecute statement="updateProduct"/>
   <flushOnExecute statement="deleteProduct"/>
   <property name="size" value="1000" />
</cacheModel>

"FIFO"(com.ibatis.db.sqlmap.cache.fifo.FifoCacheController)

캐쉬가 가득 차게 되면 가장 오래된 객체가 캐쉬에서 제거된다.

<cacheModel id="product-cache" type="FIFO">
   <flushInterval hours="24"/>
   <flushOnExecute statement="insertProduct"/>
   <flushOnExecute statement="updateProduct"/>
   <flushOnExecute statement="deleteProduct"/>
   <property name=”size” value=”1000” />
</cacheModel>

"OSCACHE"(com.ibatis.db.sqlmap.cache.oscache.OSCacheController)

highly configurable, distributed and flexible

<cacheModel id="product-cache" type="OSCACHE">
   <flushInterval hours="24"/>
   <flushOnExecute statement="insertProduct"/>
   <flushOnExecute statement="updateProduct"/>
   <flushOnExecute statement="deleteProduct"/>
</cacheModel>

루트 클래스 패스에 존재하는 oscache.properties를 통해 캐쉬를 설정

http://www.opensymphony.com/oscache 참조

7. Dynamic Mapped Statements

<select id="dynamicGetAccountList"
       cacheModel="account-cache"
       resultMap="account-result" >
   select * from ACCOUNT
       <isGreaterThan prepend="and" property="id" compareValue="0">
           where ACC_ID = #id#
       </isGreaterThan>
   order by ACC_LAST_NAME
</select>

<statement id="dynamicGetAccountList"
       resultMap="account-result" >
   select * from ACCOUNT
   <dynamic prepend="WHERE">
       <isNotNull prepend="AND" property="firstName">
           (ACC_FIRST_NAME = #firstName#
       <isNotNull prepend="OR" property="lastName">
           ACC_LAST_NAME = #lastName#
       </isNotNull>
           )
       </isNotNull>
       <isNotNull prepend="AND" property="emailAddress">
           ACC_EMAIL like #emailAddress#
       </isNotNull>
       <isGreaterThan prepend="AND" property="id" compareValue="0">
           ACC_ID = #id#
       </isGreaterThan>
   </dynamic>
   order by ACC_LAST_NAME
</statement>

<statement id="someName"
       resultMap="account-result" >
   select * from ACCOUNT
   <dynamic prepend="where">
       <isGreaterThan prepend="and" property="id" compareValue="0">

           ACC_ID = #id#
       </isGreaterThan>
       <isNotNull prepend=”and" property="lastName">

           ACC_LAST_NAME = #lastName#
       </isNotNull>
   </dynamic>

   order by ACC_LAST_NAME
</statement>

7.1 Binary Conditional Elements

binary conditional attributes는 아래와 같은 요소를 갖는다.

prepend - the overridable SQL part that will be prepended to the statement (optional)
property - the property to be compared (required)
compareProperty - the other property to be compared (required or compareValue)
compareValue - the value to be compared (required or compareProperty)

<isEqual>Checks the equality of a property and a value, or another property.
<isNotEqual>Checks the inequality of a property and a value, or another property.
<isGreaterThan>Checks if a property is greater than a value or another property
<isGreaterEqual>Checks if a property is greater than or equal to a value or another property.
<isLessThan>Checks if a property is less than a value or another property.
<isLessEqual>Checks if a property is less than or equal to a value or another property.
Example Usage:
<isLessEqual prepend=”AND” property=”age” compareValue=”18”>
   ADOLESCENT = ‘TRUE’
</isLessEqual>

7.2 Unary Conditional Elements

아래와 같은 attributes를 갖는다.

prepend - the overridable SQL part that will be prepended to the statement (optional)
property - the property to be checked (required)

<isPropertyAvailable>Checks if a property is available (i.e is a property of the parameter bean)
<isNotPropertyAvailable>Checks if a property is unavailable (i.e not a property of the parameter bean)
<isNull>Checks if a property is null.
<isNotNull>Checks if a property is not null.
<isEmpty>Checks to see if the value of a Collection, String or String.valueOf() property
is null or empty (“” or size() < 1).
<isNotEmpty> Checks to see if the value of a Collection, String or String.valueOf() property
is not null and not empty (“” or size() < 1).
Example Usage:
<isNotEmpty prepend=”AND” property=”firstName” >
   FIRST_NAME=#firstName#
</isNotEmpty>

7.3 Other Elements

Parameter Present: These elements check for parameter object existence.
Parameter Present Attributes:
prepend - the overridable SQL part that will be prepended to the statement (optional)

<isParameterPresent>Checks to see if the parameter object is present (not null).
<isNotParameterPresent>Checks to see if the parameter object is not present (null).
Example Usage:
<isNotParameterPresent prepend=”AND”>
   EMPLOYEE_TYPE = ‘DEFAULT’
</isNotParameterPresent>

Iterate: This tag will iterate over a collection and repeat the body content for each item in a List
Iterate Attributes:
prepend - the overridable SQL part that will be prepended to the statement (optional)
property - a property of type java.util.List that is to be iterated over (required)
open - the string with which to open the entire block of iterations, useful for brackets (optional)
close - the string with which to close the entire block of iterations, useful for brackets (optional)
conjunction - the string to be applied in between each iteration, useful for AND and OR (optional)

<iterate>Iterates over a property that is of type java.util.List
Example Usage:
<iterate prepend=”AND” property=”userNameList”
   open=”(” close=”)” conjunction=”OR”>
   username=#userNameList[]#
</iterate>
Note: It is very important to include the square brackets[] at the end of the List
property name when using the Iterate element. These brackets distinguish this
object as an List to keep the parser from simply outputting the List as a string.

8. Simple Dynamic SQL Elements

full dynamic mapped statement가 강력하지만 때론 간단하고 작은 SQL이 dynamic일 필요가 생긴다.

<statement id="getProduct" resultMap="get-product-result">
   select * from PRODUCT order by $preferredOrder$
</statement>

<statement id="getProduct" resultMap="get-product-result">
   SELECT * FROM PRODUCT
   <dynamic prepend="WHERE">
       <isNotEmpty property="description">
           PRD_DESCRIPTION $operator$ #description#
       </isNotEmpty>
   </dynamic>
</statement>

9. Programming with Data Mapper: The API

SqlMapClient API는 아래와 같은 4가지 주요한 기능을 제공한다.

9.1 Configuration


9.2 Transactions


9.3 Batches

많은 수의 CUD operation이 있으면 이들을 배치로 실행함으로써 네트워크 부하를 최소화하고 JDBC 드라이버로 하여금 추가적인 최적화를 수행하도록 할 수 있다(eg. compression). 2개의 메소드를 사용하여 배치 블록을 지정함으로써 쉽게 배치를 구현할 수 있다.

       sqlMap.startBatch();
       //…execute statements in between
       sqlMap.executeBatch();

9.4 Executing Statements via the SqlMapClient API

아래와 같은 API가 제공된다.

public int insert(String statementName, Object parameterObject)
       throws SQLException
public int update(String statementName, Object parameterObject)
       throws SQLException
public int delete(String statementName, Object parameterObject)
       throws SQLException
public Object queryForObject(String statementName,
Object parameterObject)
       throws SQLException
public Object queryForObject(String statementName,
Object parameterObject, Object resultObject)
       throws SQLException
public List queryForList(String statementName, Object parameterObject)
       throws SQLException
public List queryForList(String statementName, Object parameterObject,
int skipResults, int maxResults)
       throws SQLException
public List queryForList (String statementName,
Object parameterObject, RowHandler rowHandler)
       throws SQLException
public PaginatedList queryForPaginatedList(String statementName,
Object parameterObject, int pageSize)
       throws SQLException
public Map queryForMap (String statementName, Object parameterObject,
String keyProperty)
       throws SQLException
public Map queryForMap (String statementName, Object parameterObject,
String keyProperty, String valueProperty)
       throws SQLException

10. Logging SqlMap Activity with Jakarta Commons Logging

log4j.properties

   # Global logging configuration
   log4j.rootLogger=ERROR, stdout
   # SqlMap logging configuration...
   #log4j.logger.com.ibatis=DEBUG
   #log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG
   #log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG
   #log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG
   #log4j.logger.java.sql.Connection=DEBUG
   #log4j.logger.java.sql.Statement=DEBUG
   #log4j.logger.java.sql.PreparedStatement=DEBUG
   #log4j.logger.java.sql.ResultSet=DEBUG
   # Console output...
   log4j.appender.stdout=org.apache.log4j.ConsoleAppender
   log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
   log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n=

11. The One Page JavaBeans Course

12. Resources (comibatiscommonresources*)

13. SimpleDataSource (comibatiscommonjdbc*)

Property NameRequiredDefaultDescription
JDBC.DriverYesn/aThe usual JDBC driver class name.
JDBC.ConnectionURLYesn/aThe usual JDBC connection URL.
JDBC.UsernameYesn/a The username to log into the database.
JDBC.PasswordYesn/aThe password to log into the database.
JDBC.DefaultAutoCommitNodriver
dependant
The default autocommit setting for all
connections created by the pool.
Pool.MaximumActiveConnectionsNo10Maximum number of connections that can
be open at any given time.
Pool.MaximumIdleConnectionsNo 5The number of idle connections that will be
stored in the pool.
Pool.MaximumCheckoutTime No 20000The maximum length of time (milliseconds)
that a connection can be “checked out”
before it becomes a candidate for forced
collection.
Pool.TimeToWaitNo20000If a client is forced to wait for a connection
(because they are all in use), this is the
maximum length of time in (milliseconds)
that the thread will wait before making a
repeat attempt to acquire a connection. It is
entirely possible that within this time a
connection will be returned to the pool and
notify this thread. Hence, the thread may
not have to wait as long as this property
specifies (it is simply the maximum).
Pool.PingQueryNon/aThe ping query will be run against the
database to test the connection. In an
environment where connections are not
reliable, it is useful to use a ping query to
guarantee that the pool will always return a
good connection. However, this can have a
significant impact on performance. Take
care in configuring the ping query and be
sure to do a lot of testing.
Pool.PingEnabledNofalseEnable or disable ping query. For most
applications a ping query will not be
necessary.
Pool.PingConnectionsOlderThanNo0Connections that are older than the value
(milliseconds) of this property will be tested
using the ping query. This is useful if your
database environment commonly drops
connections after a period of time (e.g. 12
hours).
Pool.PingConnectionsNotUsedForNo0Connections that have been inactive for
longer than the value (milliseconds) of this
property will be tested using the ping query.
This is useful if your database environment
commonly drops connections after they have
been inactive for a period of time (e.g. after
12 hours of inactivity).
Driver.*NoN/AMany JDBC drivers support additional
features configured by sending extra
properties. To send such properties to your
JDBC driver, you can specify them by
prefixing them with “Driver.” and then the
name of the property. For example, if your
driver has a property called
“compressionEnabled”, then you can set it
in the SimpleDataSource properties by
setting “Driver.compressionEnabled=true”.
Note: These properties also work within the
dao.xml and sqlMap-config.xml files.
:
Posted by codetemplate