@RequestMapping(value = "/addmoneyid", method = RequestMethod.POST) @ResponseBody public String addCashId( @RequestParam(value = "id", required = true) Integer id, @RequestParam(value = "amount", required = true) String amount) { String sql = "call addcash((" + id + ")," + amount + ");"; String result = null; Connection connection = null; try { connection = dataSource.getConnection(); PreparedStatement ps = connection.prepareStatement(sql); ResultSet resultSet = ps.executeQuery(); while (resultSet.next()) { result = resultSet.getString(1); } resultSet.close(); ps.close(); } catch (SQLException e) { e.printStackTrace(); } finally { if (connection != null) { try { connection.close(); } catch (SQLException e) { } } } ResponseModel responseModel = new ResponseModel(); responseModel.setMessage(result); return result; }
@RequestMapping(value = "/addmoney", method = RequestMethod.POST) @ResponseBody public String addCash( @RequestParam(value = "email", required = true) String email, @RequestParam(value = "amount", required = true) String amount) { String userid = "SELECT id FROM user where email='" + email + "' AND sysdate() between validfrom and validto "; String sql = "call addcash((" + userid + ")," + amount + ");"; String result = null; Connection connection = null; try { connection = dataSource.getConnection(); PreparedStatement ps = connection.prepareStatement(sql); ResultSet resultSet = ps.executeQuery(); while (resultSet.next()) { result = resultSet.getString(1); } resultSet.close(); ps.close(); } catch (SQLException e) { e.printStackTrace(); } finally { if (connection != null) { try { connection.close(); } catch (SQLException e) { } } } ResponseModel responseModel = new ResponseModel(); responseModel.setMessage(result); return result; }