private static void createTestTables(Statement stmt, String testDbName) throws SQLException{
    // We've already dropped testDbName in constructor & we also drop it in tearDownAfterClass
    String prefix = testDbName + ".";
    String tableName = prefix + TestJdbcDriver2.tableName;
    String externalTableName = prefix + TestJdbcDriver2.externalTableName;
    String partitionedTableName = prefix + TestJdbcDriver2.partitionedTableName;
    String dataTypeTableName = prefix + TestJdbcDriver2.dataTypeTableName;
    String viewName = prefix + TestJdbcDriver2.viewName;

    // create a table
    stmt.execute("create table " + tableName
        + " (under_col int comment 'the under column', value string) comment '" + tableComment
        + "'");
    stmt.execute("create table " + tableNameWithPk
        + " (a STRING, b STRING, primary key (a) disable) ");
    // load data
    stmt.execute("load data local inpath '" + dataFilePath.toString() + "' into table " + tableName);

    // create an external table
    stmt.execute("create external table " + externalTableName + " (a int) comment '"
        + externalTableComment + "' location '" + dataFileDir + "'");

    // create a paritioned table
    stmt.execute("create table " + partitionedTableName
        + " (under_col int, value string) comment '" + partitionedTableComment
        + "' partitioned by (" + partitionedColumnName + " STRING)");
    // load data
    stmt.execute("load data local inpath '" + dataFilePath.toString() + "' into table "
        + partitionedTableName + " PARTITION (" + partitionedColumnName + "="
        + partitionedColumnValue + ")");

    // tables with various types
    stmt.execute("create table " + dataTypeTableName
        + " (c1 int, c2 boolean, c3 double, c4 string,"
        + " c5 array<int>, c6 map<int,string>, c7 map<string,string>,"
        + " c8 struct<r:string,s:int,t:double>,"
        + " c9 tinyint, c10 smallint, c11 float, c12 bigint," + " c13 array<array<string>>,"
        + " c14 map<int, map<int,int>>," + " c15 struct<r:int,s:struct<a:int,b:string>>,"
        + " c16 array<struct<m:map<string,string>,n:int>>," + " c17 timestamp, "
        + " c18 decimal(16,7), " + " c19 binary, " + " c20 date," + " c21 varchar(20),"
        + " c22 char(15)," + " c23 binary" + ") comment'" + dataTypeTableComment
        + "' partitioned by (dt STRING)");
    // load data
    stmt.execute("load data local inpath '" + dataTypeDataFilePath.toString() + "' into table "
        + dataTypeTableName + " PARTITION (dt='20090619')");

    // create view
    stmt.execute("create view " + viewName + " comment '" + viewComment + "' as select * from "
        + tableName);
    stmt.close();
  }
TestJdbcDriver2
This class tests the JDBC API for HiveServer2 via an embedded HiveServer2 instance
itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java