【发布时间】:2016-07-14 12:33:42
【问题描述】:
我正在使用spring boot jdbctemplate将记录插入数据库。但是我发现使用 jdbctemplate.update(query) ,其中 query 是用于在数据库中插入记录的字符串。
我想在表格列中插入撇号和特殊字符,但我得到 BadSqlGrammarException。
例如,我的查询是这样形成的 VALUES('abc 的例子')
我看到 Escaping a single quote when using JdbcTemplate ,在 cmets 中写到使用创建 PreparedStatement 的 jdbctemplate.update(query,Object[] args) ,但我有从每个模块调用 jdbctemplate.update() 方法的通用方法的代码。
我想将它用于插入和更新操作,目前我正在使用 jdbctemplate.update(query)
【问题讨论】:
标签: spring spring-boot spring-data