• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java HiveDriver类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.hive.jdbc.HiveDriver的典型用法代码示例。如果您正苦于以下问题:Java HiveDriver类的具体用法?Java HiveDriver怎么用?Java HiveDriver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HiveDriver类属于org.apache.hive.jdbc包,在下文中一共展示了HiveDriver类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getHiveJdbcDriver

import org.apache.hive.jdbc.HiveDriver; //导入依赖的package包/类
@Override
public Driver getHiveJdbcDriver() {
  try {
    return new HiveDriver();
  } catch ( Exception ex ) {
    throw new RuntimeException( "Unable to load Hive JDBC driver", ex );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-hadoop-shims,代码行数:9,代码来源:CommonHadoopShim.java


示例2: testGetProxyNotNull

import org.apache.hive.jdbc.HiveDriver; //导入依赖的package包/类
@Test
public void testGetProxyNotNull() throws Exception {
  assertTrue( DriverProxyInvocationChain.isInitialized() );
  if ( Boolean.parseBoolean( System.getProperty( "org.pentaho.hadoop.shims.check.hive1", "true" ) ) ) {
    // Create Hive driver
    Driver hiveDriver = new HiveDriver();
    // Create proxy to driver
    Driver driver = DriverProxyInvocationChain.getProxy( Driver.class, hiveDriver );
    assertNotNull( driver );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-hadoop-shims,代码行数:12,代码来源:DriverProxyInvocationChainTest.java


示例3: testDatabaseSelected

import org.apache.hive.jdbc.HiveDriver; //导入依赖的package包/类
@Test
public void testDatabaseSelected() throws SQLException {
  Driver driverMock = mock( HiveDriver.class );
  Driver driverProxy = DriverProxyInvocationChain.getProxy( Driver.class, driverMock );

  Connection connectionMock = mock( Connection.class );
  doReturn( connectionMock ).when( driverMock ).connect( anyString(), (Properties) isNull() );

  Statement statementMock = mock( Statement.class );
  doReturn( statementMock ).when( connectionMock ).createStatement();

  driverProxy.connect( "jdbc:hive://host:port/dbName", null );
  verify( statementMock ).execute( "use dbName" );
}
 
开发者ID:pentaho,项目名称:pentaho-hadoop-shims,代码行数:15,代码来源:DriverProxyInvocationChainTest.java


示例4: testGetTablesWithSchema

import org.apache.hive.jdbc.HiveDriver; //导入依赖的package包/类
@Test
public void testGetTablesWithSchema() throws SQLException {
  Class hive2;
  try {
    hive2 = Class.forName( "org.apache.hive.jdbc.HiveDatabaseMetaData" );
  } catch ( ClassNotFoundException e ) {
    return;
  }
  if ( hive2 != null ) {
    Driver driverMock = mock( HiveDriver.class );
    Driver driverProxy = DriverProxyInvocationChain.getProxy( Driver.class, driverMock );

    Connection connectionMock = mock( Connection.class );
    doReturn( connectionMock ).when( driverMock ).connect( anyString(), (Properties) isNull() );

    Statement statementMock = mock( Statement.class );
    doReturn( statementMock ).when( connectionMock ).createStatement();

    ResultSet resultSet = mock( ResultSet.class );
    doReturn( resultSet ).when( statementMock ).executeQuery( anyString() );

    DatabaseMetaData databaseMetaDataMock = (DatabaseMetaData) mock( hive2 );
    doReturn( databaseMetaDataMock ).when( connectionMock ).getMetaData();

    String schema = "someSchema";
    doThrow( new SQLException( "Method is not supported" ) ).when( databaseMetaDataMock )
      .getTables( null, schema, null, null );

    Connection conn = driverProxy.connect( "jdbc:hive://host:port/dbName", null );

    conn.getMetaData().getTables( null, schema, null, null );
    verify( statementMock ).execute( "use dbName" );
    verify( statementMock ).executeQuery( "show tables in " + schema );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-hadoop-shims,代码行数:36,代码来源:DriverProxyInvocationChainTest.java


示例5: driverClassName

import org.apache.hive.jdbc.HiveDriver; //导入依赖的package包/类
/**
 * @return the name of the Hive JDBC driver class used to access the database.
 */
@Override
public String driverClassName() {
  return HiveDriver.class.getName();
}
 
开发者ID:HotelsDotCom,项目名称:beeju,代码行数:8,代码来源:HiveServer2JUnitRule.java


示例6: jdbcHiveDriver

import org.apache.hive.jdbc.HiveDriver; //导入依赖的package包/类
@Bean
public Driver jdbcHiveDriver() {
  return new HiveDriver();
}
 
开发者ID:trustedanalytics,项目名称:hive-broker,代码行数:5,代码来源:ServiceInstanceProvisioningConfig.java


示例7: hiveDataSource

import org.apache.hive.jdbc.HiveDriver; //导入依赖的package包/类
@Bean
DataSource hiveDataSource() {
	return new SimpleDriverDataSource(new HiveDriver(), hiveUrl);
}
 
开发者ID:trisberg,项目名称:springone-2015,代码行数:5,代码来源:BatchHive2Configuration.java


示例8: runLoad

import org.apache.hive.jdbc.HiveDriver; //导入依赖的package包/类
private int runLoad(boolean disableMrUpdate) throws IOException, InterruptedException, ClassNotFoundException,
    SQLException {

  Configuration configuration = miniCluster.getMRConfiguration();
  writeSiteFiles(configuration);
  HiveConf hiveConf = new HiveConf(configuration, getClass());
  hiveConf.set("hive.server2.thrift.port", "0");
  HiveServer2 hiveServer2 = new HiveServer2();
  hiveServer2.init(hiveConf);
  hiveServer2.start();

  int port = waitForStartupAndGetPort(hiveServer2);

  Class.forName(HiveDriver.class.getName());
  String userName = UserGroupInformation.getCurrentUser().getShortUserName();
  Connection connection = DriverManager.getConnection("jdbc:hive2://localhost:" + port, userName, "");

  UserGroupInformation currentUser = UserGroupInformation.getCurrentUser();

  run(connection, "set blur.user.name=" + currentUser.getUserName());
  run(connection, "set blur.mr.update.disabled=" + disableMrUpdate);
  run(connection, "set hive.metastore.warehouse.dir=" + WAREHOUSE.toURI().toString());
  run(connection, "create database if not exists testdb");
  run(connection, "use testdb");

  run(connection, "CREATE TABLE if not exists testtable ROW FORMAT SERDE 'org.apache.blur.hive.BlurSerDe' "
      + "WITH SERDEPROPERTIES ( 'blur.zookeeper.connection'='" + miniCluster.getZkConnectionString() + "', "
      + "'blur.table'='" + TEST + "', 'blur.family'='" + FAM + "' ) "
      + "STORED BY 'org.apache.blur.hive.BlurHiveStorageHandler'");

  run(connection, "desc testtable");

  String createLoadTable = buildCreateLoadTable(connection);
  run(connection, createLoadTable);
  File dbDir = new File(WAREHOUSE, "testdb.db");
  File tableDir = new File(dbDir, "loadtable");
  int totalRecords = 100;
  generateData(tableDir, totalRecords);

  run(connection, "select * from loadtable");
  run(connection, "set " + BlurSerDe.BLUR_BLOCKING_APPLY + "=true");
  run(connection, "insert into table testtable select * from loadtable");
  connection.close();
  hiveServer2.stop();
  return totalRecords;
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:47,代码来源:BlurSerDeTest.java



注:本文中的org.apache.hive.jdbc.HiveDriver类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EMFObservables类代码示例发布时间:2022-05-22
下一篇:
Java XSLFPictureShape类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap