executeUpdate public int executeUpdate(String sql) throws SQLExceptionExecutes an SQL INSERT, UPDATE or DELETE statement. In addition, SQL statements that return nothing, such as SQL DDL statements, can be executed. Parameters: sql - an SQL INSERT, UPDATE or DELETE statement or an SQL statement that returns nothing Returns: either the row count for INSERT, UPDATE or DELETE statements, or 0 for SQL statements that return nothing Throws: SQLException - if a database access error occurs
executeQuery public ResultSet executeQuery(String sql) throws SQLExceptionExecutes an SQL statement that returns a single ResultSet object. Parameters: sql - typically this is a static SQL SELECT statement Returns: a ResultSet object that contains the data produced by the given query; never null Throws: SQLException - if a database access error occurs
你用excuteQuery(String str)当然要报错
public int executeUpdate(String sql)
throws SQLExceptionExecutes an SQL INSERT, UPDATE or DELETE statement. In addition, SQL statements that return nothing, such as SQL DDL statements, can be executed.
Parameters:
sql - an SQL INSERT, UPDATE or DELETE statement or an SQL statement that returns nothing
Returns:
either the row count for INSERT, UPDATE or DELETE statements, or 0 for SQL statements that return nothing
Throws:
SQLException - if a database access error occurs
public ResultSet executeQuery(String sql)
throws SQLExceptionExecutes an SQL statement that returns a single ResultSet object.
Parameters:
sql - typically this is a static SQL SELECT statement
Returns:
a ResultSet object that contains the data produced by the given query; never null
Throws:
SQLException - if a database access error occurs