01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.core;
19:
20: import java.io.PrintWriter;
21: import java.sql.Connection;
22: import java.sql.SQLException;
23:
24: import javax.sql.DataSource;
25:
26: public class ContelligentDataSource implements DataSource {
27:
28: private DataSource rawDs;
29:
30: ContelligentDataSource(DataSource raw) {
31: this .rawDs = raw;
32: }
33:
34: public Connection getConnection() throws SQLException {
35: ContelligentConnection con = ((ContelligentUserTransaction) ContelligentImpl
36: .getInstance().getUserTransaction()).getConnection();
37: if (con == null) {
38: con = new ContelligentConnection(rawDs.getConnection());
39: con.setAutoCommit(false);
40: ((ContelligentUserTransaction) ContelligentImpl
41: .getInstance().getUserTransaction())
42: .registerConnection(con);
43: }
44: return con;
45: }
46:
47: public Connection getConnection(String username, String password)
48: throws SQLException {
49: ContelligentConnection con = new ContelligentConnection(rawDs
50: .getConnection(username, password));
51: ((ContelligentUserTransaction) ContelligentImpl.getInstance()
52: .getUserTransaction()).registerConnection(con);
53: return con;
54: }
55:
56: public int getLoginTimeout() throws SQLException {
57: return rawDs.getLoginTimeout();
58: }
59:
60: public PrintWriter getLogWriter() throws SQLException {
61: return rawDs.getLogWriter();
62: }
63:
64: public void setLoginTimeout(int seconds) throws SQLException {
65: rawDs.setLoginTimeout(seconds);
66: }
67:
68: public void setLogWriter(PrintWriter out) throws SQLException {
69: rawDs.setLogWriter(out);
70: }
71:
72: }
|