Executing an insert query in hive using the JDBC API. But the query is not running. Could someone suggest what is going wrong. Also, please let me know how to capture the error code thrown by hive while running the queries. Hive version 0.13.0
When i am running the queries generated in the log in the command line they are working fine.
public static void onSuccess() {
// Write to log on Success
LOGGER.info("Job Succeeded, Updating the " + hiveDB + "." + logTable + " with status SUCCESS");
String insertOnSuccess = "insert into table " + hiveDB + "." + logTable + " select " + currentJobID + "," + "'"
+ startTime + "'" + "," + "'" + stopTime + "'" + "," + runTime + "," + "\'SUCCESS\' from " + hiveDB
+ "." + "dual" + " limit 1; ";
commonDB.InsertToTable(insertOnSuccess);
JobMailer.PostMail("IB Load Successfully completed", "Load completed");
}
public void InsertToTable(String insertquery) {
try {
stm = hiveConn.createStatement();
stm.executeUpdate(insertquery);
} catch (SQLException e) {
LOGGER.error("Running the insert query for :" + insertquery);
} catch (Exception e) {
LOGGER.error(e.getMessage());
} finally {
if (stm != null) {
try {
stm.close();
} catch (SQLException e) {
LOGGER.error(e.getMessage());
;
}
}
}
}
Here is my error log:
16/02/12 12:31:09 ERROR hiveconnector.CommonDBUtilities: Running the insert quer y for :insert into table installbase.IB_log select 25,'2016-02-12 12:26:43.037', '2016-02-12 12:31:09.057',22982400,'SUCCESS' from installbase.dual limit 1; 16/02/12 12:31:09 INFO hiveconnector.JobMailer: Sending Mail with :IB Load Succe ssfully completed 16/02/12 12:31:09 INFO hiveconnector.MainApp: Inserted record to the installbase .data_usage_governance_log Table 16/02/12 12:31:10 ERROR hiveconnector.CommonDBUtilities: Running the insert quer y for :Insert into table installbase.data_usage_governance_log select Data_Asset _Reference,File_Name,Origin_System,Transfer_System,'2016-02-12 12:26:43.037',Col umn_Reference,Element_Reference,Rule_Priority,Delete_By_Date,Classification,Geog raphic_Inclusion,Geographic_Restriction,Group_Inclusion,Group_Restriction,Reserv ed from installbase.data_usage_governance_master