private static Connection getConnection(String prefix, String postfix) throws SQLException {
    Connection con1;
    String connString = "jdbc:hive2:///" + prefix + "?" + conf.getOverlayOptionsAsQueryString()
        + ";hive.lock.manager=org.apache.hadoop.hive.ql.lockmgr.EmbeddedLockManager;" + postfix;
    LOG.info("Connection string: {}", connString);
    con1 = DriverManager
        .getConnection(connString, "", "");
    assertNotNull("Connection is null", con1);
    assertFalse("Connection should not be closed", con1.isClosed());
    return con1;
  }
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