使用jdbc连接hive库查询数据时当executeQuery方法长时间没有执行时抛出异常

zhang82772 发布于 2017/04/25 09:40
阅读 2K+
收藏 0

使用jdbc连接hive库查询数据时当executeQuery方法长时间没有执行时抛出异常

开始的时候查询正常,当查询间隔时间拉长就会抛出此异常

java.sql.SQLException: org.apache.thrift.transport.TTransportException: java.net.SocketTimeoutException: Read timed out
    at org.apache.hive.jdbc.HiveStatement.closeClientOperation(HiveStatement.java:194)
    at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:232)
    at org.apache.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:378)
    at sunline.mvc.service.quartz.QuartzCcbJdbc.executeInternal(QuartzCcbJdbc.java:89)
    at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:113)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
Caused by: org.apache.thrift.transport.TTransportException: java.net.SocketTimeoutException: Read timed out
    at org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:129)
    at org.apache.thrift.transport.TTransport.readAll(TTransport.java:86)
    at org.apache.thrift.transport.TSaslTransport.readLength(TSaslTransport.java:376)
    at org.apache.thrift.transport.TSaslTransport.readFrame(TSaslTransport.java:453)
    at org.apache.thrift.transport.TSaslTransport.read(TSaslTransport.java:435)
    at org.apache.thrift.transport.TSaslClientTransport.read(TSaslClientTransport.java:37)
    at org.apache.thrift.transport.TTransport.readAll(TTransport.java:86)
    at org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:429)
    at org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:318)
    at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:219)
    at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:77)
    at org.apache.hive.service.cli.thrift.TCLIService$Client.recv_CloseOperation(TCLIService.java:459)
    at org.apache.hive.service.cli.thrift.TCLIService$Client.CloseOperation(TCLIService.java:446)
    at sun.reflect.GeneratedMethodAccessor83.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.hive.jdbc.HiveConnection$SynchronizedHandler.invoke(HiveConnection.java:1412)
    at com.sun.proxy.$Proxy51.CloseOperation(Unknown Source)
    at org.apache.hive.jdbc.HiveStatement.closeClientOperation(HiveStatement.java:188)
    ... 6 more
Caused by: java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:152)
    at java.net.SocketInputStream.read(SocketInputStream.java:122)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
    at org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:127)
    ... 24 more
java.sql.SQLException: org.apache.thrift.transport.TTransportException: java.net.SocketException: Connection reset by peer: socket write error
    at org.apache.hive.jdbc.HiveStatement.closeClientOperation(HiveStatement.java:194)
    at org.apache.hive.jdbc.HiveStatement.close(HiveStatement.java:211)
    at sunline.mvc.service.quartz.QuartzCcbJdbc.executeInternal(QuartzCcbJdbc.java:193)
    at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:113)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
Caused by: org.apache.thrift.transport.TTransportException: java.net.SocketException: Connection reset by peer: socket write error
    at org.apache.thrift.transport.TIOStreamTransport.flush(TIOStreamTransport.java:161)
    at org.apache.thrift.transport.TSaslTransport.flush(TSaslTransport.java:501)
    at org.apache.thrift.transport.TSaslClientTransport.flush(TSaslClientTransport.java:37)
    at org.apache.thrift.TServiceClient.sendBase(TServiceClient.java:73)
    at org.apache.thrift.TServiceClient.sendBase(TServiceClient.java:62)
    at org.apache.hive.service.cli.thrift.TCLIService$Client.send_CloseOperation(TCLIService.java:453)
    at org.apache.hive.service.cli.thrift.TCLIService$Client.CloseOperation(TCLIService.java:445)
    at sun.reflect.GeneratedMethodAccessor83.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.hive.jdbc.HiveConnection$SynchronizedHandler.invoke(HiveConnection.java:1412)
    at com.sun.proxy.$Proxy51.CloseOperation(Unknown Source)
    at org.apache.hive.jdbc.HiveStatement.closeClientOperation(HiveStatement.java:188)
    ... 5 more
Caused by: java.net.SocketException: Connection reset by peer: socket write error
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:159)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
    at org.apache.thrift.transport.TIOStreamTransport.flush(TIOStreamTransport.java:159)
    ... 17 more

 

加载中
0
z
zhang82772

没有大神知道这个异常吗?

 

0
尚浩宇
尚浩宇

你该不会在这个查询中做复杂查询吧?

尚浩宇
尚浩宇
@zhang82772 回复@zhang82772 : 没事
z
zhang82772
回复 @尚浩宇 : 哦哦好的多谢解答,因为我一直做的是javaweb对这方面也是刚刚接触,有什么不会的我会在问你的。
尚浩宇
尚浩宇
@zhang82772 回复@zhang82772 : hive是做离线批处理的,他得查询本身就不是毫秒级的查询,出现连接超时也很正常,一般针对统计类型的数据会实现跑定时查询数据,然后将结果存储到其它地方比如mysql或mongo,而针对日志类型的数据,解决方案也不少,比如结合hbase做外部表、sparksql等提高查询效率
z
zhang82772
没有复杂查询就是单纯的分页然后查出来,但是中间有一部分逻辑是将数据库的图片下载到本地的,我感觉就是中间查询的间隔有些长了然后出现了读取超时。hive库中有设置这个超时时间吗?
0
ideal_github_harbby
ideal_github_harbby

@zhang82772 

DriverManager.setLoginTimeout(0);
返回顶部
顶部