kr.co.hit.live.dao.supporter
Class DbmsSupporter

java.lang.Object
  extended by kr.co.hit.live.dao.supporter.DbmsSupporter
Direct Known Subclasses:
AccessSupporter, DB2Supporter, DerbySupporter, MySQLSupporter, OracleSupporter, PostgreSQLSupporter, SqliteSupporter, SqlServerSupporter, SybaseSupporter, TeraDataSupporter, TiberoSupporter

public abstract class DbmsSupporter
extends Object

특정 Dbms를 지원하는 DbmsSupporter의 abstract class. Connection instance로 자신이 알맞은 supporter인지 판단하고, 판단이 되면 데이터 fetch시 ResultSet
을 통해 각 Column별로 알맞은 Column Reading방식을 제공한다. LOB이나 database에 의존적인 type의 Column속성이 있다면, 해당 벤더의
JDBC Type Mapping문서를 참조하여 createColumnReader를 구현해야 한다.

Since:
4.0
Version:
$Revision: 1.1 $ $Date: 2006/09/26 08:20:21 $
Author:
최승일

Field Summary
protected  ColumnReader ARRAY
           
protected  ColumnReader BIG_DECIMAL
           
protected  ColumnReader BINARY_STREAM
           
protected  ColumnReader BLOB
           
protected  ColumnReader BOOLEAN
           
protected  ColumnReader BYTE
           
protected  ColumnReader CHAR_STREAM
           
protected  ColumnReader CLOB
           
protected  ColumnReader DATE
           
protected  DefinitionMap defMap
          Definition 목록을 가지고 있는 DefinitionMap 객체
protected  ColumnReader DOUBLE
           
protected  ResultMap globalResultMap
          대상 DB용 Global ResultMap을 저장함.
protected  ColumnReader INT
           
protected  ColumnReader LONG
           
protected  ColumnReader OBJECT
           
protected  Map<String,String> postAdviceSqls
          PostSql 목록을 가지고 있는 Map 객체
protected  Map<String,String> preAdviceSqls
          PreSql 목록을 가지고 있는 Map 객체
protected  ColumnReader REAL
           
protected  ColumnReader SCALAR
           
protected  ColumnReader SHORT
           
protected  ColumnReader SIMPLEINT
           
protected  ColumnReader STRING
           
protected  ColumnReader TIME
           
protected  ColumnReader TIMESTAMP
           
 
Constructor Summary
protected DbmsSupporter(String vendor)
          생성자이다.
 
Method Summary
 void executePostAdviceSql(Connection con, String key)
          key 로 지정된 PostSQL 문장을 찾아서 수행한다.
 void executePreAdviceSql(Connection con, String key)
          key 로 지정된 PreSQL 문장을 찾아서 수행한다.
abstract  String generateTopSql(String fromSql, int topn)
          첫번째 topn 개의 row 만 조회하는 SQL 문장을 생성한다.
 ColumnReader getColumnReader(int type, String typeName)
           
 ColumnReader getDefaultColumnReader(int type, String typeName)
           
 String getDefintionValue(String name, DefinitionMap localDef)
          vendor 명칭을 사용하여 해당 definition 값을 찾는다.
abstract  String getDummyTableName()
          더미 테이블 명을 반환한다.
static DbmsSupporter getInstance(Connection conn)
           
 String getVendorName()
           
 LiveException handleSqlException(SQLException sqlex)
          DBMS 별로 차이 있는 SQLException을 처리하여 LiveException으로 반환한다.
abstract  boolean match(Connection conn)
          Connection을 통해 DbmsSupporter의 하위구현 class가 해당 Connection을 제공한 벤더의 dbms를
지원가능한지 확인한다.
abstract  PreparedStatement preparePageStatement(Connection conn, String sql, List<Object> parameters, int offset, int maxCount, Map<String,Object> args)
          Dbms마다 paging용 sql과 PreparedStatement에 설정해야 하는 값도 다르다. parameters에 설정된 key:value들은 Dbms
마다 다른 parameter들의 규약이기 때문에 해당 벤더의 supporter를 구현하는 경우에는 parameters에 설정될 값들에 대해서 정의해 주어야 한다.
 PreparedStatement prepareStatement(Connection conn, String sql, List<?> parameters)
           
 void setCallableStatementOutParam(CallableStatement cstmt, int idx, SqlParameter sqlParam)
           
 void setCallableStatementParam(CallableStatement cstmt, int idx, Object param)
           
protected  void setDefaultCallableStatementOutParam(CallableStatement cstmt, int idx, SqlParameter sqlParam)
           
protected  void setDefaultCallableStatementParam(CallableStatement cstmt, int idx, Object param)
           
protected  void setDefaultPreparedStatementParam(PreparedStatement pstmt, int idx, Object param)
           
 void setPreparedStatementParam(PreparedStatement pstmt, List<?> parameters)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

globalResultMap

protected ResultMap globalResultMap
대상 DB용 Global ResultMap을 저장함.


preAdviceSqls

protected Map<String,String> preAdviceSqls
PreSql 목록을 가지고 있는 Map 객체


postAdviceSqls

protected Map<String,String> postAdviceSqls
PostSql 목록을 가지고 있는 Map 객체


defMap

protected DefinitionMap defMap
Definition 목록을 가지고 있는 DefinitionMap 객체


BINARY_STREAM

protected final ColumnReader BINARY_STREAM

CHAR_STREAM

protected final ColumnReader CHAR_STREAM

DATE

protected final ColumnReader DATE

INT

protected final ColumnReader INT

STRING

protected final ColumnReader STRING

BOOLEAN

protected final ColumnReader BOOLEAN

BIG_DECIMAL

protected final ColumnReader BIG_DECIMAL

BYTE

protected final ColumnReader BYTE

SHORT

protected final ColumnReader SHORT

LONG

protected final ColumnReader LONG

REAL

protected final ColumnReader REAL

DOUBLE

protected final ColumnReader DOUBLE

TIME

protected final ColumnReader TIME

TIMESTAMP

protected final ColumnReader TIMESTAMP

OBJECT

protected final ColumnReader OBJECT

CLOB

protected final ColumnReader CLOB

BLOB

protected final ColumnReader BLOB

SCALAR

protected final ColumnReader SCALAR

SIMPLEINT

protected final ColumnReader SIMPLEINT

ARRAY

protected final ColumnReader ARRAY
Constructor Detail

DbmsSupporter

protected DbmsSupporter(String vendor)
생성자이다. 하위 클래스에서 해당 Vendor 명을 넣어서 호출한다.

Parameters:
vendor -
Method Detail

getVendorName

public String getVendorName()

getDefintionValue

public String getDefintionValue(String name,
                                DefinitionMap localDef)
vendor 명칭을 사용하여 해당 definition 값을 찾는다. localDef에 없으면 global definition 에서 찾는다.

Parameters:
name -
localDef -
Returns:

match

public abstract boolean match(Connection conn)
                       throws SQLException
Connection을 통해 DbmsSupporter의 하위구현 class가 해당 Connection을 제공한 벤더의 dbms를
지원가능한지 확인한다. Connection을 통해 ResultSetMetaData를 얻어와서 판별하도록 구현한다.

Parameters:
conn -
Returns:
Connection에 해당하는 Dbms를 support 가능한지의 여부.
Throws:
SQLException

getDummyTableName

public abstract String getDummyTableName()
더미 테이블 명을 반환한다. (예 : oracle은 "DUAL")

Returns:

generateTopSql

public abstract String generateTopSql(String fromSql,
                                      int topn)
첫번째 topn 개의 row 만 조회하는 SQL 문장을 생성한다.

Parameters:
fromSql - 조회대상 테이블 명 또는 SQL문
topn - 조회 건
Returns:

preparePageStatement

public abstract PreparedStatement preparePageStatement(Connection conn,
                                                       String sql,
                                                       List<Object> parameters,
                                                       int offset,
                                                       int maxCount,
                                                       Map<String,Object> args)
                                                throws SQLException
Dbms마다 paging용 sql과 PreparedStatement에 설정해야 하는 값도 다르다. parameters에 설정된 key:value들은 Dbms
마다 다른 parameter들의 규약이기 때문에 해당 벤더의 supporter를 구현하는 경우에는 parameters에 설정될 값들에 대해서 정의해 주어야 한다.

Parameters:
conn -
sql -
parameters -
offset -
maxCount -
args - 벤더별로 다른 parameter들에 대한 정의.
Returns:
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(Connection conn,
                                          String sql,
                                          List<?> parameters)
                                   throws SQLException
Throws:
SQLException

setPreparedStatementParam

public void setPreparedStatementParam(PreparedStatement pstmt,
                                      List<?> parameters)
                               throws SQLException
Throws:
SQLException

setDefaultPreparedStatementParam

protected void setDefaultPreparedStatementParam(PreparedStatement pstmt,
                                                int idx,
                                                Object param)
                                         throws SQLException
Throws:
SQLException

setCallableStatementParam

public void setCallableStatementParam(CallableStatement cstmt,
                                      int idx,
                                      Object param)
                               throws SQLException
Throws:
SQLException

setDefaultCallableStatementParam

protected void setDefaultCallableStatementParam(CallableStatement cstmt,
                                                int idx,
                                                Object param)
                                         throws SQLException
Throws:
SQLException

setCallableStatementOutParam

public void setCallableStatementOutParam(CallableStatement cstmt,
                                         int idx,
                                         SqlParameter sqlParam)
                                  throws SQLException
Throws:
SQLException

setDefaultCallableStatementOutParam

protected void setDefaultCallableStatementOutParam(CallableStatement cstmt,
                                                   int idx,
                                                   SqlParameter sqlParam)
                                            throws SQLException
Throws:
SQLException

getColumnReader

public ColumnReader getColumnReader(int type,
                                    String typeName)

getDefaultColumnReader

public ColumnReader getDefaultColumnReader(int type,
                                           String typeName)

getInstance

public static DbmsSupporter getInstance(Connection conn)
                                 throws SQLException
Throws:
SQLException

executePreAdviceSql

public void executePreAdviceSql(Connection con,
                                String key)
                         throws SQLException
key 로 지정된 PreSQL 문장을 찾아서 수행한다. Global SQL 파일에 정의된 중에서 id가 vendor명.presql.key 인 SQL 문장을 수행한다.

Parameters:
key -
Throws:
SQLException

executePostAdviceSql

public void executePostAdviceSql(Connection con,
                                 String key)
key 로 지정된 PostSQL 문장을 찾아서 수행한다. Global SQL 파일에 정의된 <statement>중에서 id가 vendor명.postsql.key 인 SQL 문장을 수행한다.

Parameters:
key -

handleSqlException

public LiveException handleSqlException(SQLException sqlex)
DBMS 별로 차이 있는 SQLException을 처리하여 LiveException으로 반환한다.

Parameters:
sqlex -
Returns:
LiveException


Copyright © 2014. All Rights Reserved.