📜  带参数的 java sql 查询 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:32.039000             🧑  作者: Mango

代码示例1
statement =con.prepareStatement("SELECT * from employee WHERE  userID = :userId");
   statement.setString(userId, userID);
   ResultSet rs = statement.executeQuery();
// Or, you can use ? in place of named value - :userId..

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