01: /**
02: * Copyright (C) 2001-2004 France Telecom R&D
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */package org.objectweb.speedo.runtime.jca;
18:
19: import java.io.PrintWriter;
20: import java.sql.Connection;
21: import java.sql.DriverManager;
22: import java.sql.SQLException;
23:
24: import javax.sql.DataSource;
25:
26: /**
27: *
28: * @author S.Chassande-Barrioz
29: */
30: public class SimpleDataSource implements DataSource {
31: private String url;
32: private String user;
33: private String password;
34: private PrintWriter pw;
35: int to = 0;
36:
37: public SimpleDataSource(String driver, String url, String user,
38: String password) throws Exception {
39: Class.forName(driver);
40: this .url = url;
41: this .user = user;
42: this .password = password;
43: }
44:
45: public Connection getConnection() throws SQLException {
46: return DriverManager.getConnection(url, user, password);
47: }
48:
49: public Connection getConnection(String username, String password)
50: throws SQLException {
51: return DriverManager.getConnection(url, username, password);
52: }
53:
54: public PrintWriter getLogWriter() throws SQLException {
55: return pw;
56: }
57:
58: public void setLogWriter(PrintWriter out) throws SQLException {
59: pw = out;
60: }
61:
62: public void setLoginTimeout(int seconds) throws SQLException {
63: to = seconds;
64: }
65:
66: public int getLoginTimeout() throws SQLException {
67: return to;
68: }
69: }
|