Passing parameters to a JDBC PreparedStatement

后端 未结 6 722
星月不相逢
星月不相逢 2020-11-28 11:45

I\'m trying to make my validation class for my program. I already establish the connection to the MySQL database and I already inserted rows into the table. The table consis

6条回答
  •  抹茶落季
    2020-11-28 12:41

    Do something like this, which also prevents SQL injection attacks

    statement = con.prepareStatement("SELECT * from employee WHERE  userID = ?");
    statement.setString(1, userID);
    ResultSet rs = statement.executeQuery();
    

提交回复
热议问题