Class DBUtils

java.lang.Object
org.owasp.dependencycheck.utils.DBUtils

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

    • getGeneratedKey

      public static int getGeneratedKey(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(Statement statement)
      Closes the given statement object ignoring any exceptions that occur.
      Parameters:
      statement - a Statement object
    • closeResultSet

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