01: package org.apache.velocity.test.sql;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21:
22: import java.io.PrintWriter;
23: import java.sql.Connection;
24: import java.sql.DriverManager;
25: import java.sql.SQLException;
26:
27: import javax.sql.DataSource;
28:
29: import org.hsqldb.jdbcDriver;
30:
31: public class HsqlDataSource implements DataSource {
32:
33: private final String url;
34:
35: private PrintWriter logWriter = null;
36:
37: private int loginTimeout = 0;
38:
39: public HsqlDataSource(final String url) throws Exception {
40: this .url = url;
41: Class.forName(jdbcDriver.class.getName());
42: }
43:
44: public Connection getConnection() throws SQLException {
45: return DriverManager.getConnection(url, "sa", "");
46: }
47:
48: public Connection getConnection(final String username,
49: final String password) throws SQLException {
50: return DriverManager.getConnection(url, username, password);
51: }
52:
53: public PrintWriter getLogWriter() throws SQLException {
54: return logWriter;
55: }
56:
57: public int getLoginTimeout() throws SQLException {
58: return loginTimeout;
59: }
60:
61: public void setLogWriter(final PrintWriter logWriter)
62: throws SQLException {
63: this .logWriter = logWriter;
64: }
65:
66: public void setLoginTimeout(final int loginTimeout)
67: throws SQLException {
68: this .loginTimeout = loginTimeout;
69: }
70:
71: public boolean isWrapperFor(final Class iface) throws SQLException {
72: return false;
73: }
74:
75: public Object unwrap(final Class iface) throws SQLException {
76: throw new SQLException("Not implemented");
77: }
78:
79: }
|