1.代码如下

String url = "jdbc:hive2://master135:10000/default";
String user = "root";
String pwd = "root"; String driverName = "org.apache.hive.jdbc.HiveDriver"; Class.forName(driverName);
Connection conn = DriverManager.getConnection(url, user, pwd); System.out.println(conn);

2.异常如下

java.sql.SQLException: enabling autocommit is not supported
at org.apache.hive.jdbc.HiveConnection.setAutoCommit(HiveConnection.java:1071) ~[hive-jdbc-1.1.0.jar:1.1.0]
at com.alibaba.druid.filter.FilterChainImpl.connection_setAutoCommit(FilterChainImpl.java:604) [druid-1.1.3.jar:1.1.3]
at com.alibaba.druid.filter.FilterAdapter.connection_setAutoCommit(FilterAdapter.java:985) ~[druid-1.1.3.jar:1.1.3]
at com.alibaba.druid.filter.FilterChainImpl.connection_setAutoCommit(FilterChainImpl.java:600) [druid-1.1.3.jar:1.1.3]
at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.setAutoCommit(ConnectionProxyImpl.java:430) ~[druid-1.1.3.jar:1.1.3]
at com.alibaba.druid.pool.DruidConnectionHolder.reset(DruidConnectionHolder.java:290) ~[druid-1.1.3.jar:1.1.3]
at com.alibaba.druid.pool.DruidDataSource.recycle(DruidDataSource.java:1505) ~[druid-1.1.3.jar:1.1.3]
at com.alibaba.druid.pool.DruidPooledConnection.recycle(DruidPooledConnection.java:324) [druid-1.1.3.jar:1.1.3]
at com.alibaba.druid.filter.FilterChainImpl.dataSource_recycle(FilterChainImpl.java:4609) [druid-1.1.3.jar:1.1.3]
at com.alibaba.druid.filter.stat.StatFilter.dataSource_releaseConnection(StatFilter.java:651) [druid-1.1.3.jar:1.1.3]
at com.alibaba.druid.filter.FilterChainImpl.dataSource_recycle(FilterChainImpl.java:4605) [druid-1.1.3.jar:1.1.3]
at com.alibaba.druid.pool.DruidPooledConnection.close(DruidPooledConnection.java:267) [druid-1.1.3.jar:1.1.3]
at org.springframework.jdbc.datasource.DataSourceUtils.doCloseConnection(DataSourceUtils.java:354) [spring-jdbc-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:341) [spring-jdbc-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.jdbc.datasource.DataSourceUtils.releaseConnection(DataSourceUtils.java:307) [spring-jdbc-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doCleanupAfterCompletion(DataSourceTransactionManager.java:386) [spring-jdbc-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.cleanupAfterCompletion(AbstractPlatformTransactionManager.java:1003) [spring-tx-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:874) [spring-tx-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:808) [spring-tx-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.test.context.transaction.TransactionContext.endTransaction(TransactionContext.java:126) [spring-test-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.test.context.transaction.TransactionalTestExecutionListener.afterTestMethod(TransactionalTestExecutionListener.java:216) [spring-test-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.test.context.TestContextManager.afterTestMethod(TestContextManager.java:435) [spring-test-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:94) [spring-test-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) [spring-test-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) [junit-4.12.jar:4.12]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251) [spring-test-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) [spring-test-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [spring-test-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) [spring-test-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) [spring-test-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) [.cp/:na]
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) [.cp/:na]
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) [.cp/:na]
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678) [.cp/:na]
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) [.cp/:na]
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) [.cp/:na]

3.解决方式1

下载hive-jdbc-uber-2.5.0.0-1245.jar或其它编译版本install到本地maven仓库

mvn install:install-file -Dfile=D:\hivejar\hive-jdbc-uber-2.5.0.0-1245.jar -DgroupId=org.apache.hive -DartifactId=hive-jdbc-uber -Dversion=2.5.0.0 -Dpackaging=jar

连接成功,不会出现异常。

Hive jdbc连接出现java.sql.SQLException: enabling autocommit is not supported的更多相关文章

  1. Hive报错之java.sql.SQLException: Field 'IS_STOREDASSUBDIRECTORIES' doesn't have a default value

    在创建表的时候报出如下错误: hive> create table if not exists testfile_table( > site string, > url string ...

  2. java.sql.SQLException: No suitable driver found for jdbc:hive://localhost:10000/default

    error: java.sql.SQLException: No suitable driver found for jdbc:hive://localhost:10000/default at ja ...

  3. JDBC连接ORACLE无法登陆java.sql.SQLException: ORA-01017: invalid username/password; logon denied

    当用jdbc连接Oracle数据库的时候 private Connection getConnection() throws SQLException { OracleDataSource ods = ...

  4. java.sql.SQLException: Could not establish connection to 192.168.8.111:10000/default: java.net.ConnectException: Connection refused: connect at org.apache.hadoop.hive.jdbc.HiveConnection.<init>(HiveC

    java.sql.SQLException: Could not establish connection to 192.168.8.111:10000/default: java.net.Conne ...

  5. Eclipse使用jdbc连接MySql数据库报:java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

    在使用eclipse连接mysql数据库时报异常: java.sql.SQLException: Access denied for user 'root'@'localhost' (using pa ...

  6. JDBC获取连接抛出java.sql.SQLException: The server time zone...

    今天尝试数据库,代码确实没问题就是给了给这个东西 java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecogniz ...

  7. HiveServer2 的jdbc方式创建udf的修改(add jar 最好不要使用),否则会造成异常: java.sql.SQLException: Error while processing statement: null

    自从Hive0.13.0开始,使用HiveServer2 的jdbc方式创建udf的临时函数的方法由: ADD JAR ${HiveUDFJarPath} create TEMPORARY funct ...

  8. java.sql.SQLException: 关闭的连接 解决办法

    程序如果长时间不进行数据库操作,那么数据源中的 Connection 很可能已经断开.其原因有可能是防火墙,或者连接的数据库设置的超时时间.这里使用的是 C3P0 连接 oracle 数据库,引起的异 ...

  9. javax.transaction.xa.XAException: java.sql.SQLException: 无法创建 XA 控制连接。(SQL 2000,SQL2005,SQL2008)

    javax.transaction.xa.XAException: java.sql.SQLException:无法创建 XA 控制连接.错误: 未能找到存储过程'master..xp_sqljdbc ...

随机推荐

  1. PowerShell (407) Proxy Authentication Required

    $Client = New-Object -TypeName System.Net.WebClient $Client.Proxy.Credentials = [System.Net.Credenti ...

  2. 根据accept-language自动设置UICulture和Culture

    在web.config中添加如下配置: <system.web> <globalization uiCulture="auto" culture="au ...

  3. 定义多个属性 Object.defineProperties()

    var book = {} Object.defineProperties(book,{ _year:{ value:2004 }, editable:{ value:1 }, year:{ get: ...

  4. #linux 下Sublime的安装

    1.Download http://www.sublimetext.com/2 Installtion use tar  解压压缩包,这里我将包改了个名字,这样就不用写空格的转义字符了,改成Subli ...

  5. Java生成不重复的随机数

    public class test { public static int[] Randoms(int number) { Random rand = new Random(); //创建一个新随机数 ...

  6. Codeforces Round #327 (Div. 2) B Rebranding(映射)

    O(1)变换映射,最后一次性替换. #include<bits/stdc++.h> using namespace std; typedef long long ll; ; char s[ ...

  7. 动态规划专题(三)——数位DP

    前言 数位\(DP\) 真的是最恶心的\(DP\). 简介 看到那种给你两个数,让你求这两个数之间符合条件的数的个数,且这两个数非常大,这样的题目一般就是 数位\(DP\) 题. 数位\(DP\)一般 ...

  8. 2017.12.25 Java中面向对象思想的深刻理解

    今日内容介绍 1.面向对象思想 2.类与对象的关系 3.局部变量和成员变量的关系 4.封装思想 5.private,this关键字 6.随机点名器 01面向对象和面向过程的思想 * A: 面向过程与面 ...

  9. 浏览器 DNS缓存与DNS prefetch (DNS预解析)

    浏览器 DNS缓存 浏览器DNS缓存的时间跟DNS服务器返回的TTL值无关. 注:TTL(Time-To-Live),就是一条域名解析记录在DNS服务器中的存留时间. 浏览器在获取网站域名的实际IP地 ...

  10. CUDA核函数参数示意:Kernel<<<Dg,Db, Ns, S>>>(param list)

    核函数是GPU每个thread上运行的程序.必须通过__gloabl__函数类型限定符定义.形式如下: __global__ void kernel(param list){  } 核函数只能在主机端 ...