|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectkr.co.hit.live.transaction.datasource.PooledDataSource
public abstract class PooledDataSource
PooledConnectionDatasource를 사용하여 Connection pooling을 관리하는 javax.sql.DataSource의 구현을 위한
상위 추상클래스이다.
Connection pooling 관리를 위한 기능을 제공하며, 실제 벤더별로 PooledConnection을
생성하는 부분은 하위 클래스에서 구현한다.
생성자에 넘겨주는 Properties 객체에 정의되는 프로퍼티들은 다음과 같다.
| Field Summary | |
|---|---|
protected String |
datasourceName
|
protected boolean |
jdbcAutoCommit
|
protected String |
jdbcDriver
|
protected String |
jdbcPassword
|
protected String |
jdbcUrl
|
protected String |
jdbcUsername
|
protected int |
poolMaxActive
|
protected int |
poolMaxIdle
|
protected long |
poolTimeToWait
|
protected int |
readTimeout
|
| Constructor Summary | |
|---|---|
PooledDataSource(Properties props)
생성자이다. |
|
| Method Summary | |
|---|---|
protected abstract Connection |
afterGetConnection(Connection con)
getConnection() 에서 Connection를 리턴하기 전에
호출되는 메소드이다. |
void |
clear()
전체 PooledConnection을 모두 close 한다. |
protected abstract PooledConnection |
createPooledConnection()
새로운 PooledConnection 객체를 생성한다. |
Connection |
getConnection()
Connection 객체를 리턴한다. |
Connection |
getConnection(String username,
String password)
주어진 사용자 아이디와 암호를 사용하여 데이터베이스에 Connection 객체를 리턴한다. |
String |
getDatasourceName()
Datasouce 명을 리턴 |
abstract int |
getLoginTimeout()
javax.sql.DataSource의 getLoginTimeout() Operation을 구현한다. |
abstract PrintWriter |
getLogWriter()
javax.sql.DataSource의 getLogWriter() Operation을 구현한다. |
protected PooledConnection |
getPooledConnection()
inactive 상태의 PooledConnection 객체를 가져온다. |
abstract void |
setLoginTimeout(int seconds)
javax.sql.DataSource의 setLoginTimeout() Operation을 구현한다. |
abstract void |
setLogWriter(PrintWriter out)
javax.sql.DataSource의 setLogWriter() Operation을 구현한다. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.sql.Wrapper |
|---|
isWrapperFor, unwrap |
| Field Detail |
|---|
protected String jdbcUsername
protected String jdbcPassword
protected String jdbcUrl
protected String jdbcDriver
protected boolean jdbcAutoCommit
protected int poolMaxActive
protected int poolMaxIdle
protected long poolTimeToWait
protected String datasourceName
protected int readTimeout
| Constructor Detail |
|---|
public PooledDataSource(Properties props)
생성자이다. 설정에 필요한 속성값들은 Properties 객체내에 정의한다.
props - 생성시 사용할 속성값들이 정의된 Properties 객체| Method Detail |
|---|
public String getDatasourceName()
Datasouce 명을 리턴
protected abstract PooledConnection createPooledConnection()
throws SQLException
새로운 PooledConnection 객체를 생성한다. 하위 클래스에서 구현한다.
SQLException
protected abstract Connection afterGetConnection(Connection con)
throws SQLException
getConnection() 에서 Connection를 리턴하기 전에
호출되는 메소드이다.
리턴하기 전에 Connection 객체에 Vendor 별로 고유한 설정이 필요한 경우 여기에 구현한다.
하위 클래스에서 구현한다.
con - 추가 설정을 할 connection 객체
SQLException
public Connection getConnection()
throws SQLException
Connection 객체를 리턴한다. 현재 Transaction 진행여부와 autocommit 설정 여부에 따라서 다음과 같이 Connection 객체를 반환한다.
getConnection in interface DataSourceSQLException - 데이터베이스 연결 시 에러가 발생할 때 또는
트랜젝션에 이미 다른 datasource 명으로 Connection 객체가 생성되어 트랜젝션에 연결되어 있는 경우
public Connection getConnection(String username,
String password)
throws SQLException
주어진 사용자 아이디와 암호를 사용하여 데이터베이스에 Connection 객체를 리턴한다. 최초 생성자에서 정의된 사용자 ID 및 암호와 서로 다른 경우에는 SQLException이 발생된다.
getConnection in interface DataSourceusername - database 연결시 사용할 사용자 IDpassword - 사용자 암호
SQLException - 사용자 아이디/암호가 최초 생성시와 다른 경우 또는 데이터베이스 연결 시 에러가 발생할 때
public abstract PrintWriter getLogWriter()
throws SQLException
javax.sql.DataSource의 getLogWriter() Operation을 구현한다.
하위 클래스에서 구현한다.
getLogWriter in interface CommonDataSourceSQLException - 데이터베이스 에러가 발생할 때
public abstract void setLogWriter(PrintWriter out)
throws SQLException
javax.sql.DataSource의 setLogWriter() Operation을 구현한다.
하위 클래스에서 구현한다.
setLogWriter in interface CommonDataSourceout - 설정할 log writer 객체
SQLException - 데이터베이스 에러가 발생할 때
public abstract int getLoginTimeout()
throws SQLException
javax.sql.DataSource의 getLoginTimeout() Operation을 구현한다.
하위 클래스에서 구현한다.
getLoginTimeout in interface CommonDataSourceSQLException - 데이터베이스 에러가 발생할 때
public abstract void setLoginTimeout(int seconds)
throws SQLException
javax.sql.DataSource의 setLoginTimeout() Operation을 구현한다.
하위 클래스에서 구현한다.
setLoginTimeout in interface CommonDataSourceseconds - 데이터베이스 로그인 최대 시간(초)
SQLException - 데이터베이스 에러가 발생할 때
protected PooledConnection getPooledConnection()
throws SQLException
inactive 상태의 PooledConnection 객체를 가져온다. Idel Pool에 PooledConnection이 있다면 그것을 꺼내와 리턴한다. Idle Pool에 PooledConnection이 존재 하지 않을 경우, Active pool의 크기가 최대치보다 작은 경우에는 새로 생성하고 Active pool의 크기가 최대치보다 크거나 같다면, idle pool에 PooledConnection이 반환될 때까지 일정시간 대기한다. 리턴되는 PooledConnection 객체는 active pool에 넣는다.
SQLException - 데이터베이스 에러가 발생할 때public void clear()
전체 PooledConnection을 모두 close 한다.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||