01: /*
02: * HA-JDBC: High-Availability JDBC
03: * Copyright (c) 2004-2007 Paul Ferraro
04: *
05: * This library is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU Lesser General Public License as published by the
07: * Free Software Foundation; either version 2.1 of the License, or (at your
08: * option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful, but WITHOUT
11: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13: * for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public License
16: * along with this library; if not, write to the Free Software Foundation,
17: * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: *
19: * Contact: ferraro@users.sourceforge.net
20: */
21: package net.sf.hajdbc.sql;
22:
23: import java.sql.Connection;
24: import java.sql.Driver;
25: import java.sql.DriverPropertyInfo;
26: import java.util.Properties;
27:
28: /**
29: * Mock driver that creates mock connections
30: * @author Paul Ferraro
31: * @since 1.1
32: */
33: @SuppressWarnings("nls")
34: public class MockDriver implements Driver {
35: private Connection connection;
36:
37: public MockDriver(Connection connection) {
38: this .connection = connection;
39: }
40:
41: /**
42: * @see java.sql.Driver#connect(java.lang.String, java.util.Properties)
43: */
44: public Connection connect(String url, Properties properties) {
45: return this .connection;
46: }
47:
48: /**
49: * @see java.sql.Driver#acceptsURL(java.lang.String)
50: */
51: public boolean acceptsURL(String url) {
52: return url.startsWith("jdbc:mock:");
53: }
54:
55: /**
56: * @see java.sql.Driver#getPropertyInfo(java.lang.String, java.util.Properties)
57: */
58: public DriverPropertyInfo[] getPropertyInfo(String url,
59: Properties properties) {
60: return new DriverPropertyInfo[0];
61: }
62:
63: /**
64: * @see java.sql.Driver#getMajorVersion()
65: */
66: public int getMajorVersion() {
67: return 0;
68: }
69:
70: /**
71: * @see java.sql.Driver#getMinorVersion()
72: */
73: public int getMinorVersion() {
74: return 0;
75: }
76:
77: /**
78: * @see java.sql.Driver#jdbcCompliant()
79: */
80: public boolean jdbcCompliant() {
81: return false;
82: }
83: }
|