当前位置: 首页 > news >正文

网站改版 优势房产网签流程及注意事项

网站改版 优势,房产网签流程及注意事项,dede网站开发步骤,上海app开发定制公司今天在移动的云平台上通过jdbc连接hive#xff0c;发现云平台使用了 kerberos的认证。与宁波实验环境不同。 发现一文解决了问题#xff0c;转载如下#xff1a; 原文地址#xff1a;http://blog.csdn.net/zengmingen/article/details/78605086 -----------------------…今天在移动的云平台上通过jdbc连接hive发现云平台使用了 kerberos的认证。与宁波实验环境不同。 发现一文解决了问题转载如下 原文地址http://blog.csdn.net/zengmingen/article/details/78605086 ------------------------------ 运用 Ambari 搭建的HDP 集群由于开启了kerberos 对外提供Hive数据时统一用JDBC 的方式所以写了下面这么一个简单样例供第三方数据接入参考。 代码如下所示 package com.bmsoft.hive.impl;import org.apache.hadoop.security.UserGroupInformation; import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement;/*** 简单的jdbc连接hive实例已开启kerberos服务)*/public class HiveSimple2 {/*** 用于连接Hive所需的一些参数设置 driverName:用于连接hive的JDBC驱动名 When connecting to* HiveServer2 with Kerberos authentication, the URL format is:* jdbc:hive2://host:port/db;principal* Server_Principal_of_HiveServer2*/private static String driverName org.apache.hive.jdbc.HiveDriver;// 注意这里的principal是固定不变的其指的hive服务所对应的principal,而不是用户所对应的principalprivate static String url jdbc:hive2://bigdata40:10000/admin;principalhive/bigdata40BIGDATA.COM;private static String sql ;private static ResultSet res;public static Connection get_conn() throws SQLException, ClassNotFoundException {/** 使用Hadoop安全登录 **/org.apache.hadoop.conf.Configuration conf new org.apache.hadoop.conf.Configuration();conf.set(hadoop.security.authentication, Kerberos);if (System.getProperty(os.name).toLowerCase().startsWith(win)) {// 默认这里不设置的话win默认会到 C盘下读取krb5.initSystem.setProperty(java.security.krb5.conf, C:/Windows/krbconf/bms/krb5.ini);} // linux 会默认到 /etc/krb5.conf 中读取krb5.conf,本文笔者已将该文件放到/etc/目录下因而这里便不用再设置了try {UserGroupInformation.setConfiguration(conf);UserGroupInformation.loginUserFromKeytab(test2/hdp39BMSOFT.COM, ./conf/test2.keytab);} catch (IOException e1) {e1.printStackTrace();}Class.forName(driverName);Connection conn DriverManager.getConnection(url);return conn;}/*** 查看数据库下所有的表** param statement* return*/public static boolean show_tables(Statement statement) {sql SHOW TABLES;System.out.println(Running: sql);try {ResultSet res statement.executeQuery(sql);System.out.println(执行“sql运行结果:);while (res.next()) {System.out.println(res.getString(1));}return true;} catch (SQLException e) {e.printStackTrace();}return false;}/*** 获取表的描述信息** param statement* param tableName* return*/public static boolean describ_table(Statement statement, String tableName) {sql DESCRIBE tableName;try {res statement.executeQuery(sql);System.out.print(tableName 描述信息:);while (res.next()) {System.out.println(res.getString(1) \t res.getString(2));}return true;} catch (SQLException e) {e.printStackTrace();}return false;}/*** 删除表** param statement* param tableName* return*/public static boolean drop_table(Statement statement, String tableName) {sql DROP TABLE IF EXISTS tableName;System.out.println(Running: sql);try {statement.execute(sql);System.out.println(tableName 删除成功);return true;} catch (SQLException e) {System.out.println(tableName 删除失败);e.printStackTrace();}return false;}/*** 查看表数据** param statement* return*/public static boolean queryData(Statement statement, String tableName) {sql SELECT * FROM tableName LIMIT 20;System.out.println(Running: sql);try {res statement.executeQuery(sql);System.out.println(执行“sql运行结果:);while (res.next()) {System.out.println(res.getString(1) , res.getString(2) , res.getString(3));}return true;} catch (SQLException e) {e.printStackTrace();}return false;}/*** 创建表** param statement* return*/public static boolean createTable(Statement statement, String tableName) {sql CREATE TABLE test_1m_test2 AS SELECT * FROM test_1m_test; // 为了方便直接复制另一张表数据来创建表System.out.println(Running: sql);try {boolean execute statement.execute(sql);System.out.println(执行结果 execute);return true;} catch (SQLException e) {e.printStackTrace();}return false;}public static void main(String[] args) {try {Connection conn get_conn();Statement stmt conn.createStatement();// 创建的表名String tableName test_100m;show_tables(stmt);// describ_table(stmt, tableName);/** 删除表 **/// drop_table(stmt, tableName);// show_tables(stmt);// queryData(stmt, tableName);createTable(stmt, tableName);conn.close();} catch (Exception e) {e.printStackTrace();} finally {System.out.println(!!!!!!END!!!!!!!!);}} } 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 pom.xml 文件如下所示 dependencies!-- https://mvnrepository.com/artifact/org.apache.hive/hive-jdbc --dependencygroupIdorg.apache.hive/groupIdartifactIdhive-jdbc/artifactIdversion1.2.1/version/dependency!-- https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-common --dependencygroupIdorg.apache.hadoop/groupIdartifactIdhadoop-common/artifactIdversion2.7.1/version/dependency!-- https://mvnrepository.com/artifact/org.apache.hive/hive-exec --dependencygroupIdorg.apache.hive/groupIdartifactIdhive-exec/artifactIdversion1.2.1/version/dependency!-- https://mvnrepository.com/artifact/org.apache.hive/hive-metastore --dependencygroupIdorg.apache.hive/groupIdartifactIdhive-metastore/artifactIdversion1.2.1/version/dependency!-- https://mvnrepository.com/artifact/org.apache.hive/hive-common --dependencygroupIdorg.apache.hive/groupIdartifactIdhive-common/artifactIdversion1.2.1/version/dependency!-- https://mvnrepository.com/artifact/org.apache.hive/hive-service --dependencygroupIdorg.apache.hive/groupIdartifactIdhive-service/artifactIdversion1.2.1/version/dependencydependencygroupIdlog4j/groupIdartifactIdlog4j/artifactIdversion1.2.17/versiontypejar/type/dependencydependencygroupIdorg.apache.hadoop/groupIdartifactIdhadoop-client/artifactIdversion2.7.3/version/dependency12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 参考文档  https://cwiki.apache.org/confluence/display/Hive/HiveServer2Clients 文档其中比较值得注意的一点是 JDBC Client Setup for a Secure Cluster When connecting to HiveServer2 with Kerberos authentication, the URL format is: jdbc:hive2://host:port/db;principalServer_Principal_of_HiveServer2123 这里的principal是固定不变的其指的hive服务所对应的principal,而不是用户所对应的principal; 对于这里的可以为不存在的数据库但是如果这么做那么在查询表的时候则需要指出其所在的库如db.tablename否则默认会查询所对应的表。
http://www.yutouwan.com/news/127261/

相关文章:

  • 宁德市蕉城区建设局网站全返利网站建设
  • 网站建设 百度百科长春网络安全公司
  • 2021年给我一个网站支付宝网站开发
  • 网站样例淘客导航网站开发
  • 搭建网站的企业Wordpress竞拍
  • 手机建网站模板太原建站模板系统
  • 模板建站排版跟没缓存好似的自己怎么做网站网页
  • 网站开发工作方向有规范
  • 梅河口建设局网站通州区网站制作
  • 河南省建设安全监督站的网站成都创意网站设计
  • 网站如何做触屏滑动网站推广怎么样
  • 郑州外语网站建站优化活动列表 wordpress
  • 国内十大知名广告公司win7系统优化软件
  • 张北县网站建设苏州企业网站建设开发
  • 泉州网站建设服务西安seo计费管理
  • 相城区公司网站建设成都网页设计培训哪家好
  • 怎么查网站外链数互联网分享社区
  • 中英互译网站怎么做进京服务的链接
  • iis5.1怎么新建网站目录浏览的网站
  • 饮食中心网站建设方案四川住房和城乡建设部官方网站
  • 怎么才能百度做网站wordpress 导航插件
  • 东圃做网站公司设计效果图制作软件
  • wdcp 快速迁移网站wordpress博客主题下载
  • 国外中文网站域名注册商张家口网站网站建设
  • 万网如何建设网站聊城定制网站建设公司
  • 网站设计做微信发现界面广告设计哪个网站好
  • 网站建设专家怎么轻松搭建自己的网站
  • 社区网站建设方案ppt网站 备案 中国 名字
  • 做爰视频网站在线看北京外贸网站设计备案
  • 罗湖网站建设的公司哪家好景安怎么把网站做别名