| 1 | |
package org.kuali.db.jdbc; |
| 2 | |
|
| 3 | |
import java.sql.Connection; |
| 4 | |
import java.sql.ResultSet; |
| 5 | |
import java.sql.SQLException; |
| 6 | |
import java.sql.Statement; |
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | 0 | public class JDBCUtils { |
| 12 | |
|
| 13 | |
public static void closeQuietly(final ResultSet rs, final Statement stmt, final Connection conn) { |
| 14 | 0 | closeQuietly(rs); |
| 15 | 0 | closeQuietly(stmt); |
| 16 | 0 | closeQuietly(conn); |
| 17 | 0 | } |
| 18 | |
|
| 19 | |
public static void closeQuietly(final Statement stmt, final Connection conn) { |
| 20 | 0 | closeQuietly(null, stmt, conn); |
| 21 | 0 | } |
| 22 | |
|
| 23 | |
public static void closeQuietly(final ResultSet rs) { |
| 24 | 0 | if (rs == null) { |
| 25 | 0 | return; |
| 26 | |
} |
| 27 | |
try { |
| 28 | 0 | rs.close(); |
| 29 | 0 | } catch (SQLException e) { |
| 30 | |
|
| 31 | 0 | } |
| 32 | 0 | } |
| 33 | |
|
| 34 | |
public static void closeQuietly(final Statement stmt) { |
| 35 | 0 | if (stmt == null) { |
| 36 | 0 | return; |
| 37 | |
} |
| 38 | |
try { |
| 39 | 0 | stmt.close(); |
| 40 | 0 | } catch (SQLException e) { |
| 41 | |
|
| 42 | 0 | } |
| 43 | 0 | } |
| 44 | |
|
| 45 | |
public static void closeQuietly(final Connection conn) { |
| 46 | 0 | if (conn == null) { |
| 47 | 0 | return; |
| 48 | |
} |
| 49 | |
try { |
| 50 | 0 | conn.close(); |
| 51 | 0 | } catch (SQLException e) { |
| 52 | |
|
| 53 | 0 | } |
| 54 | 0 | } |
| 55 | |
|
| 56 | |
public static void nullSafeRollback(final Connection conn) throws SQLException { |
| 57 | 0 | if (conn == null) { |
| 58 | 0 | return; |
| 59 | |
} |
| 60 | 0 | conn.rollback(); |
| 61 | 0 | } |
| 62 | |
|
| 63 | |
} |