简体   繁体   English

有什么更好的方法检查JdbcTemplate.batchUpdate中的名称字段,名称表的SQL注入?

[英]What better way to check SQL injection of names field, names tables in JdbcTemplate.batchUpdate?

In insert query I use SEQUENCE, because of this I refused to use SimpleJdbcInsert....executeBatch(data); 在插入查询中,我使用SEQUENCE,因此,我拒绝使用SimpleJdbcInsert .... executeBatch(data);。

String sql = "INSERT INTO "+ schema +"."+ tableName +" (id, " + fieldName1 + ", " + fieldName2 + ") VALUES (BUF_SEQ.nextval, ?, ?)";
List<Object[]> recordValues = new ArrayList<Object[]>();
//... add values of records to recordValues list

// run bash update for insert
jdbcTemplate.batchUpdate(sql, recordValues);

Maybe someone can suggest a better way use Springframework jdbc? 也许有人可以建议使用Springframework jdbc的更好方法? To insert a large number of records. 要插入大量记录。 To test the field names in the SQL injection. 在SQL注入中测试字段名称。 ?

1) Instead of calling sequence in your insert query, create a trigger on id column of the table for insert. 1)与其在插入查询中调用序列,不如在表的id列上创建触发器以进行插入。 Take ref : How to create id with AUTO_INCREMENT on Oracle? 请参考: 如何在Oracle上使用AUTO_INCREMENT创建ID?
2) Now use Batch update of spring to do bulk insertion ie jdbcTemplate.batchUpdate 2)现在使用spring的Batch update进行批量插入,即jdbcTemplate.batchUpdate
In your insert query now you no longer need to define id, every time you make insertion on the table, trigger will be fired and id will be incremented. 现在,在您的插入查询中,您不再需要定义id,每次在表上进行插入时,都会触发触发器,并且id会增加。
3) Use Prepared Statement for insert query in order to avoid sql injection. 3)使用Prepared Statement进行插入查询,以避免sql注入。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 jdbcTemplate.batchUpdate 跳过策略 - jdbcTemplate.batchUpdate Skip policy jdbctemplate.batchupdate 是多线程的还是并发的? - Is jdbctemplate.batchupdate multithreaded or concurrent? 有关大量查询的jdbcTemplate.batchUpdate()问题 - Issue with jdbcTemplate.batchUpdate() for large list of queries 批量插入使用 jdbcTemplate.batchUpdate 混淆 - Batch insert using jdbcTemplate.batchUpdate confusion 为 jdbcTemplate.batchUpdate() 方法编写单元测试 - Write unit test for jdbcTemplate.batchUpdate() method 如何包括jdbctemplate.batchUpdate(String sql,List的两个参数 <Object[]> batchArgs)? - How to include two parameters for jdbctemplate.batchUpdate(String sql, List<Object[]> batchArgs)? 为什么 Spring 的 jdbcTemplate.batchUpdate() 这么慢? - Why Spring's jdbcTemplate.batchUpdate() so slow? 列表小于 getBatchSize() 的 jdbcTemplate.batchUpdate() 抛出 IndexOutOfBoundsException 错误 - jdbcTemplate.batchUpdate() with smaller list than getBatchSize() throws IndexOutOfBoundsException error 使用spring“ jdbcTemplate.batchUpdate”进行动态插入查询的批处理 - batch processing with dynamic insert query using spring “jdbcTemplate.batchUpdate” JdbcTemplate.batchUpdate() 在一项插入错误时返回 0,但将剩余项插入 sql 服务器数据库,尽管使用 @Transactional - JdbcTemplate.batchUpdate() returns 0, on insert error for one item but inserts the remaining item into sql server db despite using @Transactional
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM