你吧SQL语句中的"改成',就是不要用\",用',试一下。错误信息太简单,有没有整个堆栈的消息?

解决方案 »

  1.   

    晕,SQL的更新语句是用excuteUpdate(String str)的。
    你用excuteQuery(String str)当然要报错
      

  2.   

    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
      

  3.   

    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
      

  4.   

    谢谢各位,我第一次写java 程序。我去试试。
      

  5.   

    谢谢各位,我第一次写java 程序。OK,问题解决。