1 |
|
package liquibase.database.jvm; |
2 |
|
|
3 |
|
import java.sql.CallableStatement; |
4 |
|
import java.sql.Connection; |
5 |
|
import java.sql.DatabaseMetaData; |
6 |
|
import java.sql.PreparedStatement; |
7 |
|
import java.sql.SQLException; |
8 |
|
import java.sql.SQLWarning; |
9 |
|
import java.sql.Savepoint; |
10 |
|
import java.sql.Statement; |
11 |
|
import java.util.Map; |
12 |
|
|
13 |
|
import liquibase.database.DatabaseConnection; |
14 |
|
import liquibase.exception.DatabaseException; |
15 |
|
import liquibase.exception.UnexpectedLiquibaseException; |
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
@author |
21 |
|
|
|
|
| 0% |
Uncovered Elements: 188 (188) |
Complexity: 93 |
Complexity Density: 0.69 |
|
22 |
|
public class JdbcConnection implements DatabaseConnection { |
23 |
|
private java.sql.Connection con; |
24 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
25 |
0
|
public JdbcConnection(java.sql.Connection connection) {... |
26 |
0
|
this.con = connection; |
27 |
|
} |
28 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
29 |
0
|
@Override... |
30 |
|
public String getDatabaseProductName() throws DatabaseException { |
31 |
0
|
try { |
32 |
0
|
return con.getMetaData().getDatabaseProductName(); |
33 |
|
} catch (SQLException e) { |
34 |
0
|
throw new DatabaseException(e); |
35 |
|
} |
36 |
|
} |
37 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
38 |
0
|
@Override... |
39 |
|
public String getDatabaseProductVersion() throws DatabaseException { |
40 |
0
|
try { |
41 |
0
|
return con.getMetaData().getDatabaseProductVersion(); |
42 |
|
} catch (SQLException e) { |
43 |
0
|
throw new DatabaseException(e); |
44 |
|
} |
45 |
|
} |
46 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
47 |
0
|
@Override... |
48 |
|
public int getDatabaseMajorVersion() throws DatabaseException { |
49 |
0
|
try { |
50 |
0
|
return con.getMetaData().getDatabaseMajorVersion(); |
51 |
|
} catch (SQLException e) { |
52 |
0
|
throw new DatabaseException(e); |
53 |
|
} |
54 |
|
} |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
56 |
0
|
@Override... |
57 |
|
public int getDatabaseMinorVersion() throws DatabaseException { |
58 |
0
|
try { |
59 |
0
|
return con.getMetaData().getDatabaseMinorVersion(); |
60 |
|
} catch (SQLException e) { |
61 |
0
|
throw new DatabaseException(e); |
62 |
|
} |
63 |
|
} |
64 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
65 |
0
|
@Override... |
66 |
|
public String getURL() { |
67 |
0
|
try { |
68 |
0
|
return con.getMetaData().getURL(); |
69 |
|
} catch (SQLException e) { |
70 |
0
|
throw new UnexpectedLiquibaseException(e); |
71 |
|
} |
72 |
|
} |
73 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
74 |
0
|
@Override... |
75 |
|
public String getConnectionUserName() { |
76 |
0
|
try { |
77 |
0
|
return con.getMetaData().getUserName(); |
78 |
|
} catch (SQLException e) { |
79 |
0
|
throw new UnexpectedLiquibaseException(e); |
80 |
|
} |
81 |
|
} |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
@return |
87 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
88 |
0
|
public Connection getWrappedConnection() {... |
89 |
0
|
return con; |
90 |
|
} |
91 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
92 |
0
|
public void clearWarnings() throws DatabaseException {... |
93 |
0
|
try { |
94 |
0
|
con.clearWarnings(); |
95 |
|
} catch (SQLException e) { |
96 |
0
|
throw new DatabaseException(e); |
97 |
|
} |
98 |
|
} |
99 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
100 |
0
|
@Override... |
101 |
|
public void close() throws DatabaseException { |
102 |
0
|
rollback(); |
103 |
0
|
try { |
104 |
0
|
con.close(); |
105 |
|
} catch (SQLException e) { |
106 |
0
|
throw new DatabaseException(e); |
107 |
|
} |
108 |
|
} |
109 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
110 |
0
|
@Override... |
111 |
|
public void commit() throws DatabaseException { |
112 |
0
|
try { |
113 |
0
|
if (!con.getAutoCommit()) { |
114 |
0
|
con.commit(); |
115 |
|
} |
116 |
|
} catch (SQLException e) { |
117 |
0
|
throw new DatabaseException(e); |
118 |
|
} |
119 |
|
} |
120 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
121 |
0
|
public Statement createStatement() throws DatabaseException {... |
122 |
0
|
try { |
123 |
0
|
return con.createStatement(); |
124 |
|
} catch (SQLException e) { |
125 |
0
|
throw new DatabaseException(e); |
126 |
|
} |
127 |
|
} |
128 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
129 |
0
|
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)... |
130 |
|
throws DatabaseException { |
131 |
0
|
try { |
132 |
0
|
return con.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); |
133 |
|
} catch (SQLException e) { |
134 |
0
|
throw new DatabaseException(e); |
135 |
|
} |
136 |
|
} |
137 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
138 |
0
|
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws DatabaseException {... |
139 |
0
|
try { |
140 |
0
|
return con.createStatement(resultSetType, resultSetConcurrency); |
141 |
|
} catch (SQLException e) { |
142 |
0
|
throw new DatabaseException(e); |
143 |
|
} |
144 |
|
} |
145 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
146 |
0
|
@Override... |
147 |
|
public boolean getAutoCommit() throws DatabaseException { |
148 |
0
|
try { |
149 |
0
|
return con.getAutoCommit(); |
150 |
|
} catch (SQLException e) { |
151 |
0
|
throw new DatabaseException(e); |
152 |
|
} |
153 |
|
} |
154 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
155 |
0
|
@Override... |
156 |
|
public String getCatalog() throws DatabaseException { |
157 |
0
|
try { |
158 |
0
|
return con.getCatalog(); |
159 |
|
} catch (SQLException e) { |
160 |
0
|
throw new DatabaseException(e); |
161 |
|
} |
162 |
|
} |
163 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
164 |
0
|
public int getHoldability() throws DatabaseException {... |
165 |
0
|
try { |
166 |
0
|
return con.getHoldability(); |
167 |
|
} catch (SQLException e) { |
168 |
0
|
throw new DatabaseException(e); |
169 |
|
} |
170 |
|
} |
171 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
172 |
0
|
public DatabaseMetaData getMetaData() throws DatabaseException {... |
173 |
0
|
try { |
174 |
0
|
return con.getMetaData(); |
175 |
|
} catch (SQLException e) { |
176 |
0
|
throw new DatabaseException(e); |
177 |
|
} |
178 |
|
} |
179 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
180 |
0
|
public int getTransactionIsolation() throws DatabaseException {... |
181 |
0
|
try { |
182 |
0
|
return con.getTransactionIsolation(); |
183 |
|
} catch (SQLException e) { |
184 |
0
|
throw new DatabaseException(e); |
185 |
|
} |
186 |
|
} |
187 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
188 |
0
|
public Map<String, Class<?>> getTypeMap() throws DatabaseException {... |
189 |
0
|
try { |
190 |
0
|
return con.getTypeMap(); |
191 |
|
} catch (SQLException e) { |
192 |
0
|
throw new DatabaseException(e); |
193 |
|
} |
194 |
|
} |
195 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
196 |
0
|
public SQLWarning getWarnings() throws DatabaseException {... |
197 |
0
|
try { |
198 |
0
|
return con.getWarnings(); |
199 |
|
} catch (SQLException e) { |
200 |
0
|
throw new DatabaseException(e); |
201 |
|
} |
202 |
|
} |
203 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
204 |
0
|
@Override... |
205 |
|
public boolean isClosed() throws DatabaseException { |
206 |
0
|
try { |
207 |
0
|
return con.isClosed(); |
208 |
|
} catch (SQLException e) { |
209 |
0
|
throw new DatabaseException(e); |
210 |
|
} |
211 |
|
} |
212 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
213 |
0
|
public boolean isReadOnly() throws DatabaseException {... |
214 |
0
|
try { |
215 |
0
|
return con.isReadOnly(); |
216 |
|
} catch (SQLException e) { |
217 |
0
|
throw new DatabaseException(e); |
218 |
|
} |
219 |
|
} |
220 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
221 |
0
|
@Override... |
222 |
|
public String nativeSQL(String sql) throws DatabaseException { |
223 |
0
|
try { |
224 |
0
|
return con.nativeSQL(sql); |
225 |
|
} catch (SQLException e) { |
226 |
0
|
throw new DatabaseException(e); |
227 |
|
} |
228 |
|
} |
229 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
230 |
0
|
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency,... |
231 |
|
int resultSetHoldability) throws DatabaseException { |
232 |
0
|
try { |
233 |
0
|
return con.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability); |
234 |
|
} catch (SQLException e) { |
235 |
0
|
throw new DatabaseException(e); |
236 |
|
} |
237 |
|
} |
238 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
239 |
0
|
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)... |
240 |
|
throws DatabaseException { |
241 |
0
|
try { |
242 |
0
|
return con.prepareCall(sql, resultSetType, resultSetConcurrency); |
243 |
|
} catch (SQLException e) { |
244 |
0
|
throw new DatabaseException(e); |
245 |
|
} |
246 |
|
} |
247 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
248 |
0
|
public CallableStatement prepareCall(String sql) throws DatabaseException {... |
249 |
0
|
try { |
250 |
0
|
return con.prepareCall(sql); |
251 |
|
} catch (SQLException e) { |
252 |
0
|
throw new DatabaseException(e); |
253 |
|
} |
254 |
|
} |
255 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
256 |
0
|
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,... |
257 |
|
int resultSetHoldability) throws DatabaseException { |
258 |
0
|
try { |
259 |
0
|
return con.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability); |
260 |
|
} catch (SQLException e) { |
261 |
0
|
throw new DatabaseException(e); |
262 |
|
} |
263 |
|
} |
264 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
265 |
0
|
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)... |
266 |
|
throws DatabaseException { |
267 |
0
|
try { |
268 |
0
|
return con.prepareStatement(sql, resultSetType, resultSetConcurrency); |
269 |
|
} catch (SQLException e) { |
270 |
0
|
throw new DatabaseException(e); |
271 |
|
} |
272 |
|
} |
273 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
274 |
0
|
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws DatabaseException {... |
275 |
0
|
try { |
276 |
0
|
return con.prepareStatement(sql, autoGeneratedKeys); |
277 |
|
} catch (SQLException e) { |
278 |
0
|
throw new DatabaseException(e); |
279 |
|
} |
280 |
|
} |
281 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
282 |
0
|
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws DatabaseException {... |
283 |
0
|
try { |
284 |
0
|
return con.prepareStatement(sql, columnIndexes); |
285 |
|
} catch (SQLException e) { |
286 |
0
|
throw new DatabaseException(e); |
287 |
|
} |
288 |
|
} |
289 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
290 |
0
|
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws DatabaseException {... |
291 |
0
|
try { |
292 |
0
|
return con.prepareStatement(sql, columnNames); |
293 |
|
} catch (SQLException e) { |
294 |
0
|
throw new DatabaseException(e); |
295 |
|
} |
296 |
|
} |
297 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
298 |
0
|
public PreparedStatement prepareStatement(String sql) throws DatabaseException {... |
299 |
0
|
try { |
300 |
0
|
return con.prepareStatement(sql); |
301 |
|
} catch (SQLException e) { |
302 |
0
|
throw new DatabaseException(e); |
303 |
|
} |
304 |
|
} |
305 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
306 |
0
|
public void releaseSavepoint(Savepoint savepoint) throws DatabaseException {... |
307 |
0
|
try { |
308 |
0
|
con.releaseSavepoint(savepoint); |
309 |
|
} catch (SQLException e) { |
310 |
0
|
throw new DatabaseException(e); |
311 |
|
} |
312 |
|
} |
313 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 4 |
Complexity Density: 1 |
|
314 |
0
|
@Override... |
315 |
|
public void rollback() throws DatabaseException { |
316 |
0
|
try { |
317 |
0
|
if (!con.getAutoCommit() && !con.isClosed()) { |
318 |
0
|
con.rollback(); |
319 |
|
} |
320 |
|
} catch (SQLException e) { |
321 |
0
|
throw new DatabaseException(e); |
322 |
|
} |
323 |
|
} |
324 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
325 |
0
|
public void rollback(Savepoint savepoint) throws DatabaseException {... |
326 |
0
|
try { |
327 |
0
|
if (!con.getAutoCommit()) { |
328 |
0
|
con.rollback(savepoint); |
329 |
|
} |
330 |
|
} catch (SQLException e) { |
331 |
0
|
throw new DatabaseException(e); |
332 |
|
} |
333 |
|
} |
334 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
335 |
0
|
@Override... |
336 |
|
public void setAutoCommit(boolean autoCommit) throws DatabaseException { |
337 |
|
|
338 |
|
|
339 |
|
|
340 |
|
|
341 |
0
|
try { |
342 |
0
|
con.setAutoCommit(autoCommit); |
343 |
|
} catch (SQLException e) { |
344 |
0
|
throw new DatabaseException(e); |
345 |
|
} |
346 |
|
|
347 |
|
} |
348 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
349 |
0
|
public void setCatalog(String catalog) throws DatabaseException {... |
350 |
0
|
try { |
351 |
0
|
con.setCatalog(catalog); |
352 |
|
} catch (SQLException e) { |
353 |
0
|
throw new DatabaseException(e); |
354 |
|
} |
355 |
|
} |
356 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
357 |
0
|
public void setHoldability(int holdability) throws DatabaseException {... |
358 |
0
|
try { |
359 |
0
|
con.setHoldability(holdability); |
360 |
|
} catch (SQLException e) { |
361 |
0
|
throw new DatabaseException(e); |
362 |
|
} |
363 |
|
} |
364 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
365 |
0
|
public void setReadOnly(boolean readOnly) throws DatabaseException {... |
366 |
0
|
try { |
367 |
0
|
con.setReadOnly(readOnly); |
368 |
|
} catch (SQLException e) { |
369 |
0
|
throw new DatabaseException(e); |
370 |
|
} |
371 |
|
} |
372 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
373 |
0
|
public Savepoint setSavepoint() throws DatabaseException {... |
374 |
0
|
try { |
375 |
0
|
return con.setSavepoint(); |
376 |
|
} catch (SQLException e) { |
377 |
0
|
throw new DatabaseException(e); |
378 |
|
} |
379 |
|
} |
380 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
381 |
0
|
public Savepoint setSavepoint(String name) throws DatabaseException {... |
382 |
0
|
try { |
383 |
0
|
return con.setSavepoint(name); |
384 |
|
} catch (SQLException e) { |
385 |
0
|
throw new DatabaseException(e); |
386 |
|
} |
387 |
|
} |
388 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
389 |
0
|
public void setTransactionIsolation(int level) throws DatabaseException {... |
390 |
0
|
try { |
391 |
0
|
con.setTransactionIsolation(level); |
392 |
|
} catch (SQLException e) { |
393 |
0
|
throw new DatabaseException(e); |
394 |
|
} |
395 |
|
} |
396 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
397 |
0
|
public void setTypeMap(Map<String, Class<?>> map) throws DatabaseException {... |
398 |
0
|
try { |
399 |
0
|
con.setTypeMap(map); |
400 |
|
} catch (SQLException e) { |
401 |
0
|
throw new DatabaseException(e); |
402 |
|
} |
403 |
|
} |
404 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
405 |
0
|
public Connection getUnderlyingConnection() {... |
406 |
0
|
return con; |
407 |
|
} |
408 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
409 |
0
|
@Override... |
410 |
|
public boolean equals(Object obj) { |
411 |
0
|
return obj instanceof JdbcConnection |
412 |
|
&& this.getUnderlyingConnection().equals(((JdbcConnection) obj).getUnderlyingConnection()); |
413 |
|
|
414 |
|
} |
415 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
416 |
0
|
@Override... |
417 |
|
public int hashCode() { |
418 |
0
|
return this.getUnderlyingConnection().hashCode(); |
419 |
|
} |
420 |
|
} |