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 {
20
21 }
22
23 public static void close(Connection con) throws SQLException
24 {
25 if (con != null && !con.isClosed())
26 {
27 con.close();
28 }
29 }
30
31 public static void commitAndClose(Connection con) throws SQLException
32 {
33 if (con != null)
34 {
35 if (!con.getAutoCommit())
36 {
37 con.commit();
38 }
39 con.close();
40 }
41 }
42
43 public static void rollbackAndClose(Connection con) throws SQLException
44 {
45 if (con != null)
46 {
47 if (!con.getAutoCommit())
48 {
49 con.rollback();
50 }
51 con.close();
52 }
53 }
54
55 }