1. ResultSet executeQuery(String sql); 执行SQL查询,并返回ResultSet 对象。
2.int executeUpdate(String sql); 可执行增,删,改,返回执行受到影响的行数。
3. boolean execute(String sql); 可执行任何SQL语句,返回一个布尔值,表示是否返回ResultSet 。sql
execute是executeQuery和executeUpdate的综合.数据库
-----缓存
executeUpdate() 这是 PreparedStatement 接口中的方法
executeUpdate(String sql) 这是 PreparedStatement 从父接口 Statement 中继承过来的方法
executeUpdate() 中执行 SQL 语句须要在建立 PerparedStatement 时经过 Connection 的 prepareStatement(String sql) 方法中写出,由于 PerparedStatement 中的 SQL 语句数据库须要进行预编译和缓存,所以要在建立 PerparedStatement 对象时给出 SQL 语句。
而 executeUpdate(String sql) 是 Statement 中的方法,参数中的 SQL 语句只是提交给数据库去执行,并不须要预编译。
若是 SQL 语句中有 ? 占位符,那么在设置好占位符中的值后,必须使用 executeUpdate() 执行。而 executeUpdate(String sql) 只是提交一个 SQL 语句,且这个语句中不能带有 ? 占位符。对象