in flume-jdbc-channel/src/main/java/org/apache/flume/channel/jdbc/impl/DerbySchemaHandler.java [531:574]
private void runQuery(String query) {
Connection connection = null;
Statement stmt = null;
try {
connection = dataSource.getConnection();
stmt = connection.createStatement();
if (stmt.execute(query)) {
ResultSet rset = stmt.getResultSet();
int count = 0;
while (rset.next()) {
count++;
}
LOGGER.info("QUERY(" + query + ") produced unused resultset with "
+ count + " rows");
} else {
int updateCount = stmt.getUpdateCount();
LOGGER.info("QUERY(" + query + ") Update count: " + updateCount);
}
connection.commit();
} catch (SQLException ex) {
try {
connection.rollback();
} catch (SQLException ex2) {
LOGGER.error("Unable to rollback transaction", ex2);
}
throw new JdbcChannelException("Unable to run query: "
+ query, ex);
} finally {
if (stmt != null) {
try {
stmt.close();
} catch (SQLException ex) {
LOGGER.error("Unable to close statement", ex);
}
if (connection != null) {
try {
connection.close();
} catch (SQLException ex) {
LOGGER.error("Unable to close connection", ex);
}
}
}
}
}