private static boolean truncateTable(Connection conn, Configuration conf, Statement stmt, String name) throws SQLException {
    String dbProduct = conn.getMetaData().getDatabaseProductName();
    DatabaseProduct databaseProduct = determineDatabaseProduct(dbProduct, conf);
    try {
      // We can not use actual truncate due to some foreign keys, but we don't expect much data during tests

      String s = databaseProduct.getTruncateStatement(name);
      stmt.execute(s);

      LOG.debug("Successfully truncated table " + name);
      return true;
    } catch (SQLException e) {
      if (databaseProduct.isTableNotExistsError(e)) {
        LOG.debug("Not truncating " + name + " because it doesn't exist");
        return true;
      }
      LOG.error("Unable to truncate table " + name, e);
    }
    return false;
  }
Prepares the metastore database for unit tests.
Runs the latest init schema against the database configured in the CONNECT_URL_KEY param.
Ignores any duplication (table, index etc.) So it can be called multiple times for the same database.
@param conf Metastore configuration
@throws Exception Initialization failure
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/utils/TestTxnDbUtil.java