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