Spring jdbc模板更新方法

Spring jdbc模板更新方法,spring,jdbctemplate,Spring,Jdbctemplate,我向Rest控制器发送了一个POST请求 @RequestMapping(value = "/addUser", method = {RequestMethod.POST}) public String addThisUser(@RequestBody String json) { String result = ""; try { JSONObject jsonObject = new JSONObject(json); result =

我向Rest控制器发送了一个POST请求

  @RequestMapping(value = "/addUser", method = {RequestMethod.POST})
public String addThisUser(@RequestBody String json)
  {
    String result = "";
    try
    {
      JSONObject jsonObject = new JSONObject(json);
      result = addUser.addTheUser(jsonObject.getString("firstName"),
              jsonObject.getString("lastName"), jsonObject.getInt("age"),
              jsonObject.getString("email"), jsonObject.getLong("phoneNumber"),
              jsonObject.getString("username"), jsonObject.getString("password"));
    }
    catch(JSONException exception)
    {
      result = "Something went wrong. Try again later";
    }
    return result;
  }
然后,我尝试使用JdbcTemplate将值插入表中。但是它不起作用,我也不知道为什么。下面是代码(我得到一个DataAccessException):

我还想指出,select语句工作正常:

  String queryString = "SELECT * FROM userInformation";


  List<Map<String, Object>> listOfUsers = dbConnecter.queryForList(queryString);
String queryString=“从用户信息中选择*”;
List ListoUsers=dbConnecter.queryForList(queryString);

我真的不知道为什么会这样。有人能帮忙吗?

一条清晰的错误消息有助于提供更好的答案。但如果需要,请尝试以下方法:

Statement statement = dbConnection.createStatement();
statement.executeUpdate(updateTableSQL);

你有异常跟踪吗?如果是,请提供。显示的错误是什么?什么不起作用?我使用了PreparedStatement界面,它起作用了!多谢各位much@Maths2468很高兴你觉得它有用
Statement statement = dbConnection.createStatement();
statement.executeUpdate(updateTableSQL);