Debian Codegraph @

src/test/java/com/zaxxer/hikari/mocks/StubDriver.java

raw
1 /*
2 * Copyright (C) 2013 Brett Wooldridge
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package com.zaxxer.hikari.mocks;
18
19 import java.sql.Connection;
20 import java.sql.Driver;
21 import java.sql.DriverManager;
22 import java.sql.DriverPropertyInfo;
23 import java.sql.SQLException;
24 import java.sql.SQLFeatureNotSupportedException;
25 import java.util.Properties;
26 import java.util.logging.Logger;
27
28 /**
29 *
30 * @author Brett Wooldridge
31 */
32 public class StubDriver implements Driver
33 {
34 private static final Driver driver;
35
36 static
37 {
38 driver = new StubDriver();
39 try
40 {
41 DriverManager.registerDriver(driver);
42 }
43 catch (SQLException e)
44 {
45 e.printStackTrace();
46 }
47 }
48
49 /** {@inheritDoc} */
50 @Override
51 public Connection connect(String url, Properties info) throws SQLException
52 {
53 return new StubConnection();
54 }
55
56 /** {@inheritDoc} */
57 @Override
58 public boolean acceptsURL(String url) throws SQLException
59 {
60 return "jdbc:stub".equals(url);
61 }
62
63 /** {@inheritDoc} */
64 @Override
65 public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException
66 {
67 return null;
68 }
69
70 /** {@inheritDoc} */
71 @Override
72 public int getMajorVersion()
73 {
74 return 0;
75 }
76
77 /** {@inheritDoc} */
78 @Override
79 public int getMinorVersion()
80 {
81 return 0;
82 }
83
84 /** {@inheritDoc} */
85 @Override
86 public boolean jdbcCompliant()
87 {
88 return true;
89 }
90
91 /** {@inheritDoc} */
92 public Logger getParentLogger() throws SQLFeatureNotSupportedException
93 {
94 return null;
95 }
96 }