JDBC到配置单元连接在无效操作上失败isValid() [英] JDBC to hive connection fails on invalid operation isValid()

查看:3307
本文介绍了JDBC到配置单元连接在无效操作上失败isValid()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循这个文档,试图建立一个jdbc连接到蜂巢。但日食显示这个错误。似乎没有弄清楚它到底意味着什么,并且与适当的密码和用户名的连接工作在直线中,所以它不是认证的问题。下面是我面临的错误:

 > 15/11/27 13:15:41信息jdbc.Utils:提供的权限:localhost:10000 
> 15/11/27 13:15:41信息jdbc.Utils:解决权限:localhost:10000
> 15/11/27 13:15:41 INFO jdbc.HiveConnection:将尝试使用JDBC打开客户端传输Uri:jdbc:hive2:// localhost:10000 / default
>线程main中的异常java.sql.SQLException:不支持方法
在org.apache.hive.jdbc.HiveConnection.isValid(HiveConnection.java:1026)
在HiveJDBC.main(HiveJDBC.java :21)

这里是代码:

  import java.sql.SQLException; 
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.DriverManager;

public class HiveJDBC {
private static String driverName =org.apache.hive.jdbc.HiveDriver;

public static void main(String [] args)throws SQLException {
try {
Class.forName(driverName);
$ b $ catch(ClassNotFoundException e){
// TODO自动生成的catch块
e.printStackTrace();
System.exit(1);

Connection con = DriverManager.getConnection(jdbc:hive2:// localhost:10000 / default,hive,PASSWORD);
if(con.isValid(0)){
System.out.println(success);
} else {
System.out.println(fail);
}

Statement stmt = con.createStatement();
String tableName =tabledriver;
//stmt.executeQuery(\"create database+ tableName);


$ b


解决方案

您打电话给

  if(con.isValid(0)){

legal - 但不是由Hive JDBC Driver实施。



请参阅 Hive Source

  @Override 
public boolean isValid(int timeout)抛出SQLException {
// TODO自动生成的方法存根
抛出新的SQLException(Method not supported);
}

用一个简单的取代检查if(con! = null),你会没事的。

I have followed this doc to try to set up a jdbc connection to hive. But eclipse shows this error. Not seem to figure out what it exactly means and the connection with appropriate password and username works in beeline so its not the problem of authentication.Below is the error i'm facing:

> 15/11/27 13:15:41 INFO jdbc.Utils: Supplied authorities: localhost:10000
> 15/11/27 13:15:41 INFO jdbc.Utils: Resolved authority: localhost:10000
> 15/11/27 13:15:41 INFO jdbc.HiveConnection: Will try to open client transport with JDBC Uri: jdbc:hive2://localhost:10000/default
> Exception in thread "main" java.sql.SQLException: Method not supported
    at org.apache.hive.jdbc.HiveConnection.isValid(HiveConnection.java:1026)
    at HiveJDBC.main(HiveJDBC.java:21)

here is the code:

import java.sql.SQLException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.DriverManager;

public class HiveJDBC {
  private static String driverName = "org.apache.hive.jdbc.HiveDriver";

  public static void main(String[] args) throws SQLException {
    try {
      Class.forName(driverName);

    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      System.exit(1);
    }
    Connection con = DriverManager.getConnection("jdbc:hive2://localhost:10000/default", "hive", "PASSWORD");
    if(con.isValid(0)){
        System.out.println("success");
    }else{
        System.out.println("fail");
    }

    Statement stmt = con.createStatement();
    String tableName = "tabledriver";
    //stmt.executeQuery("create database " + tableName);

  }
}

解决方案

Your call to

if(con.isValid(0)){

is legal - but not implemented by the Hive JDBC Driver.

See Hive Source:

@Override
public boolean isValid(int timeout) throws SQLException {
  // TODO Auto-generated method stub
  throw new SQLException("Method not supported");
}

Replace the check with a simple if(con != null) and you'll be fine.

这篇关于JDBC到配置单元连接在无效操作上失败isValid()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆