The method setint(int, String) is undefined for the type PreparedStatement
时间: 2024-04-30 13:18:01 浏览: 191
The method `setint(int, String)` is not a valid method for the `PreparedStatement` class in Java. Perhaps you meant to use `setInt(int parameterIndex, int x)` to set an integer value for a parameter at the specified index in the SQL statement. Example usage:
```
PreparedStatement ps = conn.prepareStatement("INSERT INTO mytable (id, name) VALUES (?, ?)");
ps.setInt(1, 123);
ps.setString(2, "John");
ps.executeUpdate();
```
This code creates a prepared statement for an SQL INSERT statement with two parameters, sets the first parameter to an integer value of 123 using `setInt()`, and sets the second parameter to a string value of "John" using `setString()`. Finally, it executes the SQL statement using `executeUpdate()`.
阅读全文