kr.co.hit.live.transaction.datasource
Class SimpleDataSource

java.lang.Object
  extended by kr.co.hit.live.transaction.datasource.SimpleDataSource
All Implemented Interfaces:
Wrapper, CommonDataSource, DataSource

public class SimpleDataSource
extends Object
implements DataSource

Pooling 기능이 없는 javax.sql.DataSource의 구현이다. Transaction 여부에 따라서 새로운 Connection 객체 또는 기존에 생성된 Connection 객체를 리턴한다.

생성자에 넘겨주는 Properties 객체에 정의되는 프로퍼티들은 다음과 같다.

Since:
3.0
Version:
$Revision: 1.1 $ $Date: 2006/09/26 08:20:10 $
Author:
김형도

Field Summary
protected  String datasourceName
           
protected  boolean jdbcAutoCommit
           
protected  String jdbcDriver
           
protected  String jdbcPassword
           
protected  String jdbcUrl
           
protected  String jdbcUsername
           
 
Constructor Summary
SimpleDataSource(Properties props)
           생성자이다.
 
Method Summary
 Connection getConnection()
           Connection 객체를 리턴한다.
 Connection getConnection(String username, String password)
           주어진 사용자 아이디와 암호를 사용하여 데이터베이스에 Connection 객체를 리턴한다.
 String getDatasourceName()
           Datasouce 명을 리턴한다.
 int getLoginTimeout()
           DriverManager 클래스의 getLoginTimeout()를 호출한다.
 PrintWriter getLogWriter()
           DriverManager 클래스의 getLogWriter()를 호출한다.
 boolean isWrapperFor(Class<?> iface)
           
 void setLoginTimeout(int seconds)
           DriverManager 클래스의 setLoginTimeout()를 호출한다.
 void setLogWriter(PrintWriter out)
           DriverManager 클래스의 setLogWriter()를 호출한다.
<T> T
unwrap(Class<T> iface)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jdbcUsername

protected String jdbcUsername

jdbcPassword

protected String jdbcPassword

jdbcUrl

protected String jdbcUrl

jdbcDriver

protected String jdbcDriver

jdbcAutoCommit

protected boolean jdbcAutoCommit

datasourceName

protected String datasourceName
Constructor Detail

SimpleDataSource

public SimpleDataSource(Properties props)

생성자이다. 설정에 필요한 속성값들은 Properties 객체내에 정의한다.

Parameters:
props - 생성시 사용할 속성값들이 정의된 Properties 객체
Method Detail

getDatasourceName

public String getDatasourceName()

Datasouce 명을 리턴한다.


getConnection

public Connection getConnection()
                         throws SQLException

Connection 객체를 리턴한다. 현재 Transaction 진행여부와 autocommit 설정 여부에 따라서 다음과 같이 Connection 객체를 반환한다.

Specified by:
getConnection in interface DataSource
Returns:
Connection 객체
Throws:
SQLException - 데이터베이스 연결 시 에러가 발생할 때 또는 트랜젝션에 이미 다른 datasource 명으로 Connection 객체가 생성되어 트랜젝션에 연결되어 있는 경우

getConnection

public Connection getConnection(String username,
                                String password)
                         throws SQLException

주어진 사용자 아이디와 암호를 사용하여 데이터베이스에 Connection 객체를 리턴한다.

Specified by:
getConnection in interface DataSource
Parameters:
username - database 연결시 사용할 사용자 ID
password - 사용자 암호
Returns:
Connection 객체
Throws:
SQLException - 데이터베이스 연결 시 에러가 발생할 때, Datasource 설정과 다른 User/Password를 지정했을 때

getLogWriter

public PrintWriter getLogWriter()
                         throws SQLException

DriverManager 클래스의 getLogWriter()를 호출한다.

Specified by:
getLogWriter in interface CommonDataSource
Returns:
log writer 객체를 리턴, 설정되지 않은 경우에는 null을 리턴
Throws:
SQLException - 데이터베이스 에러가 발생할 때

setLogWriter

public void setLogWriter(PrintWriter out)
                  throws SQLException

DriverManager 클래스의 setLogWriter()를 호출한다.

Specified by:
setLogWriter in interface CommonDataSource
Parameters:
out - 설정할 log writer 객체
Throws:
SQLException - 데이터베이스 연결 시 에러가 발생할 때

getLoginTimeout

public int getLoginTimeout()
                    throws SQLException

DriverManager 클래스의 getLoginTimeout()를 호출한다.

Specified by:
getLoginTimeout in interface CommonDataSource
Returns:
데이터베이스 로그인 최대 시간(초)
Throws:
SQLException - 데이터베이스 에러가 발생할 때

setLoginTimeout

public void setLoginTimeout(int seconds)
                     throws SQLException

DriverManager 클래스의 setLoginTimeout()를 호출한다.

Specified by:
setLoginTimeout in interface CommonDataSource
Parameters:
seconds - 데이터베이스 로그인 최대 시간(초)
Throws:
SQLException - 데이터베이스 에러가 발생할 때

isWrapperFor

public boolean isWrapperFor(Class<?> iface)
                     throws SQLException
Specified by:
isWrapperFor in interface Wrapper
Throws:
SQLException

unwrap

public <T> T unwrap(Class<T> iface)
         throws SQLException
Specified by:
unwrap in interface Wrapper
Throws:
SQLException


Copyright © 2014. All Rights Reserved.