View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.shardingsphere.driver.state.circuit.connection;
19  
20  import org.apache.shardingsphere.driver.jdbc.unsupported.AbstractUnsupportedOperationConnection;
21  import org.apache.shardingsphere.driver.state.circuit.metadata.CircuitBreakerDatabaseMetaData;
22  import org.apache.shardingsphere.driver.state.circuit.statement.CircuitBreakerPreparedStatement;
23  import org.apache.shardingsphere.driver.state.circuit.statement.CircuitBreakerStatement;
24  
25  import java.sql.Array;
26  import java.sql.Clob;
27  import java.sql.DatabaseMetaData;
28  import java.sql.PreparedStatement;
29  import java.sql.SQLException;
30  import java.sql.SQLFeatureNotSupportedException;
31  import java.sql.SQLWarning;
32  import java.sql.Savepoint;
33  import java.sql.Statement;
34  
35  /**
36   * Circuit breaker connection.
37   */
38  public final class CircuitBreakerConnection extends AbstractUnsupportedOperationConnection {
39      
40      @Override
41      public DatabaseMetaData getMetaData() {
42          return new CircuitBreakerDatabaseMetaData();
43      }
44      
45      @Override
46      public void setReadOnly(final boolean readOnly) {
47      }
48      
49      @Override
50      public boolean isReadOnly() {
51          return false;
52      }
53      
54      @Override
55      public void setCatalog(final String catalog) {
56      }
57      
58      @Override
59      public String getCatalog() {
60          return "";
61      }
62      
63      @Override
64      public void setSchema(final String schema) {
65      }
66      
67      @Override
68      public String getSchema() {
69          return "";
70      }
71      
72      @Override
73      public void setTransactionIsolation(final int level) {
74      }
75      
76      @Override
77      public int getTransactionIsolation() {
78          return TRANSACTION_NONE;
79      }
80      
81      @Override
82      public SQLWarning getWarnings() {
83          return null;
84      }
85      
86      @Override
87      public void clearWarnings() {
88      }
89      
90      @Override
91      public void setAutoCommit(final boolean autoCommit) {
92      }
93      
94      @Override
95      public boolean getAutoCommit() {
96          return false;
97      }
98      
99      @Override
100     public void commit() {
101     }
102     
103     @Override
104     public void rollback() {
105     }
106     
107     @Override
108     public void rollback(final Savepoint savepoint) throws SQLException {
109         throw new SQLFeatureNotSupportedException("rollback savepoint");
110     }
111     
112     @Override
113     public Savepoint setSavepoint() throws SQLException {
114         throw new SQLFeatureNotSupportedException("setSavepoint");
115     }
116     
117     @Override
118     public Savepoint setSavepoint(final String name) throws SQLException {
119         throw new SQLFeatureNotSupportedException("setSavepoint name");
120     }
121     
122     @Override
123     public void releaseSavepoint(final Savepoint savepoint) throws SQLException {
124         throw new SQLFeatureNotSupportedException("releaseSavepoint");
125     }
126     
127     @Override
128     public void setHoldability(final int holdability) {
129     }
130     
131     @Override
132     public int getHoldability() {
133         return 0;
134     }
135     
136     @Override
137     public PreparedStatement prepareStatement(final String sql) {
138         return new CircuitBreakerPreparedStatement();
139     }
140     
141     @Override
142     public PreparedStatement prepareStatement(final String sql, final int resultSetType, final int resultSetConcurrency) {
143         return new CircuitBreakerPreparedStatement();
144     }
145     
146     @Override
147     public PreparedStatement prepareStatement(final String sql, final int resultSetType, final int resultSetConcurrency, final int resultSetHoldability) {
148         return new CircuitBreakerPreparedStatement();
149     }
150     
151     @Override
152     public PreparedStatement prepareStatement(final String sql, final int autoGeneratedKeys) {
153         return new CircuitBreakerPreparedStatement();
154     }
155     
156     @Override
157     public PreparedStatement prepareStatement(final String sql, final int[] columnIndexes) {
158         return new CircuitBreakerPreparedStatement();
159     }
160     
161     @Override
162     public PreparedStatement prepareStatement(final String sql, final String[] columnNames) {
163         return new CircuitBreakerPreparedStatement();
164     }
165     
166     @Override
167     public Statement createStatement() {
168         return new CircuitBreakerStatement();
169     }
170     
171     @Override
172     public Statement createStatement(final int resultSetType, final int resultSetConcurrency) {
173         return new CircuitBreakerStatement();
174     }
175     
176     @Override
177     public Statement createStatement(final int resultSetType, final int resultSetConcurrency, final int resultSetHoldability) {
178         return new CircuitBreakerStatement();
179     }
180     
181     @Override
182     public boolean isValid(final int timeout) {
183         return true;
184     }
185     
186     @Override
187     public Clob createClob() {
188         return null;
189     }
190     
191     @Override
192     public Array createArrayOf(final String typeName, final Object[] elements) {
193         return null;
194     }
195     
196     @Override
197     public boolean isClosed() {
198         return false;
199     }
200     
201     @Override
202     public void close() {
203     }
204 }