I have a sql query, works fine, but I want to show a JSON response, with the result, like fetchall in python, I can the result with a "while" but, there a "fetchall" for java?
This is my code, I want to show the query result in a JSON response:
@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"));
}