Hive SQLException: Method not supported问题
概述
项目使用到 impala/hive 查询引擎,ELK记录每天都要抛出差不多一两条报错信息:java.net.SocketTimeoutException: Read timed out
。原因应该是SQL比较复杂,查询超时。故而可以考虑设置超时时间。
参考SocketTimeoutException: Read timed out 问题解决,以为万事大吉,结果代码上线之后,出现另外一个报错:SQLException: Method not supported
问题
并且是疯狂(半小时内成千上万条)报错:java.sql.SQLException: Method not supported
。
改动有两点:
- URL链接
jdbc:hive2://impala.aaacorp.com:25005/edw
增加配置,变成jdbc:hive2://impala.aaacorp.com:25005/edw?hive.metastore.client.socket.timeout=1800&hive.server.read.socket.timeout=1800&hive.server.write.socket.timeout=1800&hive.server.thrift.socket.timeout=1800&hive.client.thrift.socket.timeout=1800
statement = connection.createStatement();
// 新增
statement.setQueryTimeout(queryTimeout);
去掉放在Apollo配置里面的URL更改,没有解决问题,报错依旧。
那就是代码的问题,找到源码:
public class HiveStatement implements Statement {@Overridepublic void setQueryTimeout(int seconds) throws SQLException {throw new SQLException("Method not supported");}
}
找到问题根源!!!
使用的hive-jdbc版本:
<dependency><groupId>org.apache.hive</groupId><artifactId>hive-jdbc</artifactId><version>1.1.0-cdh5.7.1</version>
</dependency>
另外,hadoop版本:2.6.0-cdh5.7.1
经过与数仓同事咨询,搭建的集群版本为cdh-6.2版本。在maven仓库搜索新版本,升级到如下版本解决这个报错:
<dependency><groupId>org.apache.hive</groupId><artifactId>hive-jdbc</artifactId><version>2.1.1-cdh6.2.1</version>
</dependency>
查看源码得到验证:
public void setQueryTimeout(int seconds) throws SQLException {this.queryTimeout = seconds;
}
SQLException: Method not supported
比较详细的报错日志如下:
2022-05-05 18:19:18.069 [ERROR][http-nio-8081-exec-2]:c.alibaba.druid.pool.DruidPooledPreparedStatement [<init>:82] getMaxFieldSize error
java.sql.SQLException: Method not supportedat org.apache.hive.jdbc.HiveStatement.getMaxFieldSize(HiveStatement.java:579)at com.alibaba.druid.pool.DruidPooledPreparedStatement.<init>(DruidPooledPreparedStatement.java:80)at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:425)
重点看报错堆栈里面的getMaxFieldSize
方法。应用使用druid连接池 + JDBC方式获取各种不同的数据源连接。
解决方案是在获取连接的时候判断一下不同数据源:
if (!driver.equalsIgnoreCase(DbDriverTypeEnum.IMPALA.getDbDriverType())) {conf.put(PROP_POOLPREPAREDSTATEMENTS, "true");conf.put(PROP_MAXOPENPREPAREDSTATEMENTS, "20");
}@Getter
@AllArgsConstructor
public enum DbDriverTypeEnum {//HIVE("hive", "org.apache.hive.jdbc.HiveDriver", "jdbc"),MYSQL("mysql", "com.mysql.cj.jdbc.Driver", "jdbc"),;private final String name;private final String dbDriverType;private final String connectionType;
}
参考
Java连接Hive踩坑血泪
hive批量新增报错:ERROR c.a.d.p.DruidPooledPreparedStatement - getMaxFieldSize error
Hive SQLException: Method not supported问题相关推荐
- hive | 解决character '' not supported here
今天在处理数据入库时出现了character '' not supported here的bug 经过问题排查,是在执行 load DATA LOCAL inpath 'XXX' overwrite ...
- resultset 的指针报错原因
调试的代码如下: stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); ...
- 2018年第31周-hive支持的Delete和Update的配置
配置hive-site.xml hive.support.concurrency = true hive.enforce.bucketing = true hive.exec.dynamic.part ...
- Hive学习之路 (九)Hive的内置函数
数学函数 Return Type Name (Signature) Description DOUBLE round(DOUBLE a) Returns the rounded BIGINT valu ...
- hive最新UDF函数(2016-10-25)
为什么80%的码农都做不了架构师?>>> hive UDF函数 :(后期翻译,暂时先贴着,有兴趣来 http://apache.wiki 可以一起来翻译呀) https:// ...
- EZDML连接hive数据仓库建模实践
理论上EZDML可以通过JDBC连接所有数据库,之前有网友跟我说EZDML通过JDBC连接hive有问题,我自己不玩数据仓库,对hive不熟,不过我想正常来说都是JDBC封装了,不应该啊.因此这几天我 ...
- Hive时间(日期)函数
Hive内置函数地址 https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF 日期函数 Hive 中支持以下内置日期函数 ...
- sqoop连接hive和mysql_用Sqoop进行Hive和MySQL之间的数据互导
Hive导数据入MySQL 创建mysql表 use anticheat; create table anticheat_blacklist( userid varchar(30) primary k ...
- hive mysql互导_Hive和MySQL数据互导
Hive导数据入MySQL 建立与hbase表映射的hive,用sqoop导入mysql 创建mysql表 use anticheat; create table newsinfo_anticheat ...
- hive内嵌时间日期函数:所有关于时间日期的函数
日期函数在hive中很常用,甚至有时候要自定义时间函数.首先hive中存放的数据经常是按时间分区进行存储的,有时候按时间分区的时间就是从日志中国解析出来的时间,或者有时候截取时间进行区间划分.比如我们 ...
最新文章
- 《20170914-构建之法:现代软件工程-阅读笔记》
- 【干货】APP产品处理加载机制和刷新机制的交互方法解析
- fasttext的异步随机梯度下降导致结果不一致
- 关于SAP Cloud for Customer Cloud Application Studio登录失败的问题
- 使用 kind 快速搭建一个 Kubernetes 测试环境
- 好用的前端组件收集(ing)
- flowable 监听器中无法获取 oauth 上下文对象
- 阿里云吴磊创办yunQ云桥,完成银杏谷资本2000万元天使轮融资...
- 子元素和后代元素的区别
- 重庆崽儿,啷个能不回重庆撒!
- 2.1 八边形绘制
- 关于国密HTTPS的那些事(一)
- hexo部署到云服务器
- 微信模板消息推送心得
- python网络爬虫学习资料
- 判断一个数是否为素数的一个讨论(一)
- syntaxhighlighter修饰代码时,底部出现水平滚动条
- win10 为什么可以秒开机?(附实战源码,真机操作)
- STM32F0系列串口DMA收发数据
- 服务市场系统解耦及数据异构设计架构
热门文章
- python之parser.add_argument()用法——命令行选项、参数和子命令解析器
- geek_How-To Geek正在寻找远程全职技术作家
- orge terrain
- 电脑不停自动安装垃圾软件怎么办
- winrar.msi_如何使WinRAR自动化以从setup.exe和MSI文件制作单个文件安装程序
- MySQL 中 TIMESTAMP 类型返回日期时间数据中带有 T
- 外置硬盘一插就卡_为什么电脑一插移动硬盘就卡死了?
- 嘿嘿,长假最后一天!摸鱼一把,我用Python做一个美女消消乐!
- 新建的module没有蓝色小块
- CryEngine 动态添加模型