如何使用java代码通过json请求在mysql中保存hindi字符

时间:2017-02-02 05:39:38

标签: java sql spring

@RequestMapping(value = "/MultiLingual", method = RequestMethod.GET,consumes={"application/json; charset=UTF-8"})
@ResponseBody public String hi(@RequestParam("name") String name ,HttpServletResponse httpServletResponse) throws IOException {

    httpServletResponse.setCharacterEncoding("UTF-8");

    System.out.println(name +"(((((((( अलविदा");

    int update  = jdbcTemplate.update("INSERT INTO multi_lingual(Name) values(?)",name);
    String nameAlvida = jdbcTemplate.queryForObject("Select name from multi_lingual order by ID DESC limit 0,1", String.class);
    System.out.println(update+" ::: update"); 
    if(update>0)
    {
        System.out.println("inserted");

    }
     System.out.println(" "+StringEscapeUtils.unescapeJava(name));

    return "success = "    +nameAlvida;

}

1 个答案:

答案 0 :(得分:0)

您只需要进行一些更改。

#update Table properties
ALTER TABLE table_name CHANGE column_name column_name VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

#update database properties
datasource.url = jdbc:mysql://localhost:3306/DBName?useUnicode=yes&characterEncoding=UTF-8