Coverage Report - org.mule.transport.jdbc.JdbcUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
JdbcUtils
0%
0/15
0%
0/12
2.25
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.transport.jdbc;
 8  
 
 9  
 import java.sql.Connection;
 10  
 import java.sql.SQLException;
 11  
 
 12  
 /**
 13  
  * Utility methods for working with various parts of JDBC.
 14  
  */
 15  
 public final class JdbcUtils
 16  
 {
 17  
 
 18  
     private JdbcUtils()
 19  0
     {
 20  
         // empty, just to restrict instanciation
 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  
 }