01: /* Copyright 2004 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal.rdbm;
07:
08: import java.io.PrintWriter;
09: import java.sql.Connection;
10: import java.sql.SQLException;
11:
12: import javax.sql.DataSource;
13:
14: import org.apache.commons.dbcp.BasicDataSource;
15:
16: /**
17: * A DataSource implementation backed by an in-memory HSQLDb instance,
18: * suitable for implementing testcases for DataSource-consuming DAO impls.
19: * @author andrew.petro@yale.edu
20: * @version $Revision: 35073 $ $Date: 2004-11-17 12:17:28 -0700 (Wed, 17 Nov 2004) $
21: */
22: public class TransientDatasource implements DataSource {
23:
24: private DataSource delegate;
25:
26: public TransientDatasource() {
27:
28: BasicDataSource basicDataSource = new BasicDataSource();
29: basicDataSource.setMaxActive(1);
30: basicDataSource.setInitialSize(1);
31: basicDataSource.setDriverClassName("org.hsqldb.jdbcDriver");
32: basicDataSource.setUrl("jdbc:hsqldb:mem:adhommemds");
33: basicDataSource.setMaxIdle(0);
34:
35: this .delegate = basicDataSource;
36:
37: }
38:
39: /* (non-Javadoc)
40: * @see javax.sql.DataSource#getConnection()
41: */
42: public Connection getConnection() throws SQLException {
43: return this .delegate.getConnection();
44: }
45:
46: public Connection getConnection(String arg0, String arg1)
47: throws SQLException {
48: return this .delegate.getConnection();
49: }
50:
51: /* (non-Javadoc)
52: * @see javax.sql.DataSource#getLogWriter()
53: */
54: public PrintWriter getLogWriter() throws SQLException {
55: // TODO Auto-generated method stub
56: return null;
57: }
58:
59: /* (non-Javadoc)
60: * @see javax.sql.DataSource#getLoginTimeout()
61: */
62: public int getLoginTimeout() throws SQLException {
63: // TODO Auto-generated method stub
64: return 0;
65: }
66:
67: /* (non-Javadoc)
68: * @see javax.sql.DataSource#setLogWriter(java.io.PrintWriter)
69: */
70: public void setLogWriter(PrintWriter arg0) throws SQLException {
71: // TODO Auto-generated method stub
72:
73: }
74:
75: /* (non-Javadoc)
76: * @see javax.sql.DataSource#setLoginTimeout(int)
77: */
78: public void setLoginTimeout(int arg0) throws SQLException {
79: // TODO Auto-generated method stub
80:
81: }
82:
83: }
|