[英]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.