Class DBUtils


  • @ThreadSafe
    public final class DBUtils
    extends java.lang.Object
    Collection of utility methods for working with database objects.
    Author:
    Jeremy Long
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void closeResultSet​(java.sql.ResultSet rs)
      Closes the result set capturing and ignoring any SQLExceptions that occur.
      static void closeStatement​(java.sql.Statement statement)
      Closes the given statement object ignoring any exceptions that occur.
      static int getGeneratedKey​(java.sql.PreparedStatement statement)
      Returns the generated integer primary key for a newly inserted row.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getGeneratedKey

        public static int getGeneratedKey​(java.sql.PreparedStatement statement)
                                   throws DatabaseException
        Returns the generated integer primary key for a newly inserted row.
        Parameters:
        statement - a prepared statement that just executed an insert
        Returns:
        a primary key
        Throws:
        DatabaseException - thrown if there is an exception obtaining the key
      • closeStatement

        public static void closeStatement​(java.sql.Statement statement)
        Closes the given statement object ignoring any exceptions that occur.
        Parameters:
        statement - a Statement object
      • closeResultSet

        public static void closeResultSet​(java.sql.ResultSet rs)
        Closes the result set capturing and ignoring any SQLExceptions that occur.
        Parameters:
        rs - a ResultSet to close