1 /* $Id: DataSourceWrapper.java 94 2008-12-18 11:07:17Z dobashi $
\r
3 * (c)2005 Lavans Networks Inc. All Rights Reserved.
\r
5 package com.lavans.luz2.sql;
\r
7 import java.io.PrintWriter;
\r
8 import java.sql.Connection;
\r
9 import java.sql.SQLException;
\r
11 import javax.sql.DataSource;
\r
18 public class DataSourceWrapper implements DataSource{
\r
19 private int loginTimeout=0;
\r
20 private String dbName="default";
\r
22 /** logwriter.この実装でいいのか? */
\r
23 private PrintWriter logWriter = null;
\r
24 // private Logger logger = Logger.getLogger(DataSourceWrapper.class);
\r
27 * コンストラクタ。データベース名指定なし。
\r
28 * 設定ファイルのdefaultセクションを使用する。
\r
31 public DataSourceWrapper(){
\r
36 * コンストラクタ。データベース名指定あり。
\r
37 * 設定ファイルのセクション名を指定できる。
\r
40 public DataSourceWrapper(String dbName){
\r
41 this.dbName = dbName;
\r
45 * @see javax.sql.DataSource#getConnection()
\r
47 public Connection getConnection() throws SQLException {
\r
48 return DBManager.getConnection(dbName);
\r
52 * コネクションの取得。user/pass指定。
\r
53 * user/passは設定ファイルから取得するのでここで指定した値は無効。
\r
54 * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String)
\r
56 public Connection getConnection(String arg0, String arg1)
\r
57 throws SQLException {
\r
58 return DBManager.getConnection(dbName);
\r
62 * @see javax.sql.DataSource#getLoginTimeout()
\r
64 public int getLoginTimeout() throws SQLException {
\r
65 return loginTimeout;
\r
68 * @see javax.sql.DataSource#getLogWriter()
\r
70 public PrintWriter getLogWriter() throws SQLException {
\r
74 * @see javax.sql.DataSource#setLoginTimeout(int)
\r
76 public void setLoginTimeout(int arg0) throws SQLException {
\r
77 loginTimeout = arg0;
\r
80 * @see javax.sql.DataSource#setLogWriter(java.io.PrintWriter)
\r
82 public void setLogWriter(PrintWriter logWriter) throws SQLException {
\r
83 this.logWriter = logWriter;
\r
87 public boolean isWrapperFor(Class<?> arg0) throws SQLException {
\r
89 // if(arg0 instanceof DataSource){
\r
95 @SuppressWarnings("unchecked")
\r
97 public <T> T unwrap(Class<T> arg0) throws SQLException {
\r