有没有办法通过jdbc使Impala上的元数据无效?
我尝试了以下内容(我使用的是Cloudera_ImpalaJDBC4_2.5.5.1007驱动程序):
// invalidate metadata and rebuild index on Impala
try {
Statement stmt = impalaConn.createStatement();
try {
String query = "INVALIDATE METADATA;";
ResultSet resultSet = stmt.executeQuery(query);
while (resultSet.next()) {
// do something
}
}
finally {
stmt.close();
}
}
catch(SQLException ex) {
while (ex != null)
{
ex.printStackTrace();
ex = ex.getNextException();
}
System.exit(1);
}
但我得到以下例外:
java.sql.SQLDataException: [Simba][JDBC](11300) A ResultSet was expected but not generated from query "INVALIDATE METADATA;". Query not executed.
at com.cloudera.impala.exceptions.ExceptionConverter.toSQLException(ExceptionConverter.java:136)
at com.cloudera.impala.jdbc.common.SStatement.checkCondition(SStatement.java:2274)
at com.cloudera.impala.jdbc.common.SStatement.executeNoParams(SStatement.java:2704)
at com.cloudera.impala.jdbc.common.SStatement.executeQuery(SStatement.java:880)
at ico.az.deploy.TestSuite.testTeradata(TestSuite.java:103)
at ico.az.deploy.TestSuite.run(TestSuite.java:310)
at ico.az.deploy.TestSuite.main(TestSuite.java:345)
有什么想法吗?
答案 0 :(得分:3)
是。该查询不会返回ResultSet
。请改用Statement.executeUpdate(String)
。正如JavaDoc所说,为了强调,添加了粗体,执行给定的SQL语句,该语句可以是INSERT,UPDATE或DELETE语句或不返回任何内容的SQL语句 。 / p>
stmt.executeUpdate(query);