情景
我正在尝试通过zookeepers集群将配置单元表从本地笔记本连接到远程开发服务器,并尝试更新表列值。hadoop集群和hive表也远程位于dev环境中。我正在使用hive-jdbc.jar版本2.1.0和hadoop公共版本2.7.1
发行
面临更新表记录但stmt.getupdatecount()和stmt.executeupdate分别返回-1和0的问题。代码:有什么遗漏吗??或者在配置单元表中getupdatecount()的行为不同?感谢您的快速帮助。。
代码:
private static String driverName = "org.apache.hive.jdbc.HiveDriver";
public static void main(String[] args) throws SQLException,
ClassNotFoundException {
Class.forName(driverName);
Connection con =
DriverManager.getConnection("jdbc:hive2://XXXX:XXXX/tibco,
XXXX:XXXX/tibco,XXXX:XXXX/tibco;
serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2;
"hive.execution.engine=tez", "hive", "");
Statement stmt = con.createStatement();
con.setAutoCommit(true);
System.out.println("created");
ResultSet rs = stmt.executeQuery("select * from tibco.log_events_poc");
ResultSet db1=stmt.executeQuery("desc tibco.log_events_poc");
System.out.println("tibco.log_events_poc table -->"+db1);
int rowsupdated = stmt.executeUpdate("update tibco.log_events_poc set
name='sample1'");
System.out.println("Number of Rows updated"+stmt.getUpdateCount());
System.out.println("Number of Rows updated"+rowsupdated);
stmt.close();
con.close();
}
1条答案
按热度按时间ergxz8rk1#
您可以查看版本2.1.0的源代码。驱动程序完全忽略任何更新计数并始终返回
0
:相关功能请求如下:https://issues.apache.org/jira/browse/hive-12382