У меня есть SQL-запрос, работает нормально, но я хочу показать ответ JSON, с результатом, как fetchall в python, я могу получить результат с помощью «while», но есть «fetchall» для java?
Это мой код, я хочу показать результат запроса в ответе JSON:
@RequestMapping(value="/parity/{date}", method=RequestMethod.GET,
produces = "application/json")
public ResponseEntity parity(@PathVariable String date) throws SQLException {
String[] a = date.split("-");
date = a[0].substring(2) + a[1] + a[2];
Connection connection = ConnectionS.getInstance().getConnection(env);
String selectSql = "SELECT EX FROM TS1.EXC WHERE EXT = '"+ date +"' AND EXR=1";
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(selectSql);
//the fetchall here for translate a JSONresponse below
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new JsonResponse("ok"));
}