1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.transport.jdbc; |
8 | |
|
9 | |
import java.sql.Connection; |
10 | |
import java.sql.SQLException; |
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
public final class JdbcUtils |
16 | |
{ |
17 | |
|
18 | |
private JdbcUtils() |
19 | 0 | { |
20 | |
|
21 | 0 | } |
22 | |
|
23 | |
public static void close(Connection con) throws SQLException |
24 | |
{ |
25 | 0 | if (con != null && !con.isClosed()) |
26 | |
{ |
27 | 0 | con.close(); |
28 | |
} |
29 | 0 | } |
30 | |
|
31 | |
public static void commitAndClose(Connection con) throws SQLException |
32 | |
{ |
33 | 0 | if (con != null) |
34 | |
{ |
35 | 0 | if (!con.getAutoCommit()) |
36 | |
{ |
37 | 0 | con.commit(); |
38 | |
} |
39 | 0 | con.close(); |
40 | |
} |
41 | 0 | } |
42 | |
|
43 | |
public static void rollbackAndClose(Connection con) throws SQLException |
44 | |
{ |
45 | 0 | if (con != null) |
46 | |
{ |
47 | 0 | if (!con.getAutoCommit()) |
48 | |
{ |
49 | 0 | con.rollback(); |
50 | |
} |
51 | 0 | con.close(); |
52 | |
} |
53 | 0 | } |
54 | |
|
55 | |
} |