Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st. We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here. Need help or have questions? Drop us a line at [email protected]
public class SparkServer2Client { private static final Logger LOGGER = LoggerFactory.getLogger(SparkServer2Client.class); private static String HIVESERVE2DRIVER = "org.apache.hive.jdbc.HiveDriver";
public static void main(String[] args) throws SQLException, IOException {
// set the configurationConfiguration conf = new Configuration(); conf.set("hadoop.security.authentication", "Kerberos"); UserGroupInformation.setConfiguration(conf); // /etc/security/keytab/hive.service.keytab is from local machine, This is the user which is executing the commandUserGroupInformation.loginUserFromKeytab("hive/[email protected]", "/etc/security/keytab/hive.service.keytab");
// load the drivertry { Class.forName(HIVESERVE2DRIVER); } catch (ClassNotFoundException e) { LOGGER.error("Driver not found"); }
Connection con = DriverManager.getConnection("jdbc:hive2://hostname.com:10016/default;httpPath=/;principal=hive/[email protected]"); Statement stmt = con.createStatement();