@SuppressWarnings("deprecation")
  @BeforeClass
  public static void setUpBeforeClass() throws Exception {
    conf = new HiveConfForTest(TestJdbcDriver2.class);
    TestTxnDbUtil.setConfValues(conf);
    TestTxnDbUtil.prepDb(conf);
    dataFileDir = conf.get("test.data.files").replace('\\', '/')
        .replace("c:", "");
    dataFilePath = new Path(dataFileDir, "kv1.txt");
    dataFileRowCount = 500;
    dataTypeDataFilePath = new Path(dataFileDir, "datatypes.txt");
    // Create test database and base tables once for all the test
    Class.forName(driverName);
    System.setProperty(ConfVars.HIVE_SERVER2_LOGGING_OPERATION_LEVEL.varname, "verbose");
    System.setProperty(ConfVars.HIVE_MAPRED_MODE.varname, "nonstrict");
    System.setProperty(ConfVars.HIVE_AUTHORIZATION_MANAGER.varname,
        "org.apache.hadoop.hive.ql.security.authorization.DefaultHiveAuthorizationProvider");
    System.setProperty(ConfVars.HIVE_SERVER2_PARALLEL_OPS_IN_SESSION.varname, "false");
    System.setProperty(ConfVars.REPL_CM_ENABLED.varname, "true");
    System.setProperty(ConfVars.REPL_CM_DIR.varname, "cmroot");

    con = getConnection(defaultDbName + ";create=true", "");
    Statement stmt = con.createStatement();
    assertNotNull("Statement is null", stmt);
    stmt.execute("set hive.support.concurrency = false");
    stmt.execute("drop database if exists " + testDbName + " cascade");
    stmt.execute("create database " + testDbName);
    stmt.execute("use " + testDbName);
    createTestTables(stmt, testDbName);
    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