![](/img/trans.png)
[英]How to prevent SQL second order injections in java (Spring Application)
[英]SQL injections (java)
我試圖找出一種方法來根據用戶輸入查看sql注入是否正確,如果是,請刪除該行。 例如,用戶為idNumber輸入123,如果該數字退出,則sql語句“ select * from student,其中idNumber =“ + idNumber +”;“ 是正確的。 驗證正確后,我將使用另一條語句刪除查詢。 我的主要問題是弄清楚如何驗證它是正確的。
謝謝!
public static void CheckStudent(Connection con, String idNumber) throws SQLException {
Statement stmt = null;
String query = "select * from student where idNumber = " + idNumber + ";"
try {
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
if (!rs.isBeforeFirst() ) {
//Here is where you do the check
System.out.println("No data");
}
} catch (SQLException e ) {
JDBCTutorialUtilities.printSQLException(e);
} finally {
if (stmt != null) { stmt.close(); }
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.