1 package org.apache.velocity.test.sql;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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, final String password)
49 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) throws SQLException {
62 this.logWriter = logWriter;
63 }
64
65 public void setLoginTimeout(final int loginTimeout) throws SQLException {
66 this.loginTimeout = loginTimeout;
67 }
68
69 public boolean isWrapperFor(final Class iface) throws SQLException {
70 return false;
71 }
72
73 public Object unwrap(final Class iface) throws SQLException {
74 throw new SQLException("Not implemented");
75 }
76
77 }