}
}
@Override
public void read(ILineSender lineSender){
DBResultSetSender proxy = DBResultSetSender.newSender(lineSender);
proxy.setMonitor(getMonitor());
proxy.setDateFormatMap(genDateFormatMap());
if(sql.isEmpty()){
logger.error("Sql for mysqlReader is empty.");
throw new WormholeException("Sql for mysqlReader is empty.",JobStatus.READ_FAILED.getStatus()+ERROR_CODE_ADD);
}
logger.debug(String.format("MysqlReader start to query %s .", sql));
for(String sqlItem:sql.split(";")){
sqlItem = sqlItem.trim();
if(sqlItem.isEmpty()) {
continue;
}
logger.debug(sqlItem);
ResultSet rs = null;
try {
rs = DBUtils.query(conn, sqlItem);
proxy.sendToWriter(rs);
proxy.flush();
} catch (SQLException e) {
logger.error("Mysql read failed",e);
throw new WormholeException(e,JobStatus.READ_FAILED.getStatus()+ERROR_CODE_ADD);
} catch (WormholeException e1) {
e1.setStatusCode(e1.getStatusCode() + ERROR_CODE_ADD);