简体   繁体   中英

How to prevent my website from sql Injection? Struts

how to prevent my website from doing sql injection in it

I am working using Struts 2 , DB MY sql .

The best way I think is to not re-invent the wheel and use the tools already available. For a small project I would recommend to simply use prepared statements when querying your database.

http://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.html

You could also look into using an ORM like Hybernate. But make sure to use it as intended. Even HQL can be susceptible to injection. See: how much safe from SQL-Injection if using hibernate

The important thing is to not write your own native queries by concatenating query strings with values from untrusted sources.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM