Class TransactionJdbcUtils

java.lang.Object
io.github.blyznytsiaorg.bibernate.transaction.TransactionJdbcUtils

public class TransactionJdbcUtils extends Object
The TransactionJdbcUtils class provides utility methods for handling JDBC resources in the context of transactions. It encapsulates methods to close JDBC connections and prepared statements, considering the transactional context.

The class includes methods to close both PreparedStatement and Connection objects, ensuring proper handling of resources and exceptions.

This utility class is designed to simplify the management of JDBC resources, ensuring proper handling of exceptions and avoiding common pitfalls related to connection management in transactional contexts.

Since:
1.0
Author:
Blyzhnytsia Team
See Also:
  • Constructor Details

    • TransactionJdbcUtils

      public TransactionJdbcUtils()
  • Method Details

    • close

      public static void close(Connection connection, PreparedStatement ps)
      Closes both the provided Connection and PreparedStatement objects. This method ensures proper resource handling, and any exceptions during the process are encapsulated in a BibernateGeneralException.
      Parameters:
      connection - The JDBC connection to close
      ps - The prepared statement to close
      Throws:
      BibernateGeneralException - If an error occurs while closing the resources
    • close

      public static void close(PreparedStatement ps)
      Closes the provided PreparedStatement object. This method ensures proper resource handling, and any exceptions during the process are encapsulated in a BibernateGeneralException.
      Parameters:
      ps - The prepared statement to close
      Throws:
      BibernateGeneralException - If an error occurs while closing the prepared statement
    • close

      public static void close(Connection connection)
      Closes the provided Connection object if there is no active transaction. This method checks if there is an active transaction using the TransactionHolder, and only closes the connection if there is no active transaction. Any exceptions during the process are encapsulated in a BibernateGeneralException.
      Parameters:
      connection - The JDBC connection to close
      Throws:
      BibernateGeneralException - If an error occurs while closing the connection