executeUpdate();
时间: 2023-11-18 22:02:22 浏览: 30
executeUpdate() is a method in Java that is used to execute SQL statements that modify data in a database. It is typically used to execute INSERT, UPDATE, or DELETE statements. The method returns an integer value that represents the number of rows affected by the executed statement. If no rows are affected, the method returns 0.
For example, the following code snippet shows how to use executeUpdate() to insert a new row into a table:
```
String sql = "INSERT INTO customers (name, email) VALUES ('John Smith', 'johnsmith@email.com')";
int rowsAffected = statement.executeUpdate(sql);
```
In this example, the SQL statement inserts a new row into the "customers" table with the name "John Smith" and email "johnsmith@email.com". The executeUpdate() method is called with the SQL statement as a parameter, and the number of rows affected by the statement is stored in the "rowsAffected" variable.