Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
StaticSource |
|
| 1.7;1.7 |
1 | /** | |
2 | * Copyright (c) 2012-2015, jcabi.com | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: 1) Redistributions of source code must retain the above | |
8 | * copyright notice, this list of conditions and the following | |
9 | * disclaimer. 2) Redistributions in binary form must reproduce the above | |
10 | * copyright notice, this list of conditions and the following | |
11 | * disclaimer in the documentation and/or other materials provided | |
12 | * with the distribution. 3) Neither the name of the jcabi.com nor | |
13 | * the names of its contributors may be used to endorse or promote | |
14 | * products derived from this software without specific prior written | |
15 | * permission. | |
16 | * | |
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT | |
19 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
20 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | |
21 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
28 | * OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 | */ | |
30 | package com.jcabi.jdbc; | |
31 | ||
32 | import java.io.PrintWriter; | |
33 | import java.sql.Connection; | |
34 | import java.util.logging.Logger; | |
35 | import javax.sql.DataSource; | |
36 | import lombok.EqualsAndHashCode; | |
37 | import lombok.ToString; | |
38 | ||
39 | /** | |
40 | * Static data source. | |
41 | * | |
42 | * @author Yegor Bugayenko (yegor@teamed.io) | |
43 | * @version $Id: f121d2d2654b013cfe3f526a715e9e8accc504aa $ | |
44 | * @since 0.10 | |
45 | */ | |
46 | 0 | @ToString |
47 | 0 | @EqualsAndHashCode(of = "conn") |
48 | final class StaticSource implements DataSource { | |
49 | ||
50 | /** | |
51 | * The connection. | |
52 | */ | |
53 | private final transient Connection conn; | |
54 | ||
55 | /** | |
56 | * Public ctor. | |
57 | * @param cnx Connection | |
58 | */ | |
59 | 0 | StaticSource(final Connection cnx) { |
60 | 0 | this.conn = cnx; |
61 | 0 | } |
62 | ||
63 | @Override | |
64 | public Connection getConnection() { | |
65 | 0 | return this.conn; |
66 | } | |
67 | ||
68 | @Override | |
69 | public Connection getConnection(final String username, | |
70 | final String password) { | |
71 | 0 | return this.conn; |
72 | } | |
73 | ||
74 | @Override | |
75 | public PrintWriter getLogWriter() { | |
76 | 0 | throw new UnsupportedOperationException("#getLogWriter()"); |
77 | } | |
78 | ||
79 | @Override | |
80 | public void setLogWriter(final PrintWriter writer) { | |
81 | 0 | throw new UnsupportedOperationException("#setLogWriter()"); |
82 | } | |
83 | ||
84 | @Override | |
85 | public void setLoginTimeout(final int seconds) { | |
86 | 0 | throw new UnsupportedOperationException("#setLoginTimeout()"); |
87 | } | |
88 | ||
89 | @Override | |
90 | public int getLoginTimeout() { | |
91 | 0 | throw new UnsupportedOperationException("#getLoginTimeout()"); |
92 | } | |
93 | ||
94 | @Override | |
95 | public Logger getParentLogger() { | |
96 | 0 | throw new UnsupportedOperationException("#getParentLogger()"); |
97 | } | |
98 | ||
99 | @Override | |
100 | public <T> T unwrap(final Class<T> iface) { | |
101 | 0 | throw new UnsupportedOperationException("#unwrap()"); |
102 | } | |
103 | ||
104 | @Override | |
105 | public boolean isWrapperFor(final Class<?> iface) { | |
106 | 0 | throw new UnsupportedOperationException("#isWrapperFor()"); |
107 | } | |
108 | ||
109 | } |