我正在尝试通过zookeepers集群将本地笔记本电脑中的Hive表连接到远程开发服务器,并尝试更新表列值。 Hadoop集群和Hive表也位于开发环境的远程位置。 我正在使用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();
}
答案 0 :(得分:0)
You can check out the sources of version 2.1.0。驱动程序完全忽略任何更新计数,并始终返回'Find out number of sheets in Master
Set MasterWB = ActiveWorkbook
MScnt = MasterWB.Sheets.Count
'Switch to folder containing data workbooks
'Use path from master for now
ChDir ("\\C:Test")
'Find al xlsx workbooks in folder
File = Dir("*.xlsx")
While File <> ""
Debug.Print "Processing file " & File
'Do not process yourself
If InStr(File, MasterWB.Name) = 0 Then
'Open data workbook
Set DataWB = Workbooks.Open(File, xlUpdateLinksNever, True)
DataWB.Activate
'Catch missing input sheet
On Error Resume Next
Snr = 0
Snr = Sheets("2. Hours Reconciliation").Index
On Error GoTo 0
If Snr > 0 Then
Sheets(Snr).Copy After:=MasterWB.Sheets(1)
MasterWB.Activate
'Rename added sheet; use data wb name for now
End If
MasterWB.Activate
DataWB.Close False
End If
'Next file
File = Dir()
Wend
:
0