多个结果集的处理
jdbcTemplate.execute(
new StatementCallback() {
@Override
public Object doInStatement(Statement statement) throws SQLException, DataAccessException {
boolean hadResults = statement.execute("CALL p_a_AdInfo('127.0.0.1',1)");
while (hadResults) {
ResultSet rs = statement.getResultSet();
while (rs != null && rs.next()) {
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
for (int i = 0; i < columnCount; i++) {
String columnName = rsmd.getColumnLabel(i + 1);
log.info("columnName:{} columnValue:{}", columnName, rs.getObject(i + 1));
}
}
hadResults = statement.getMoreResults();
}
return null;
}
}
);
通过 getColumnLabel 获取列的别名 getColumnName 获取的是数据库字段名
评论区