CYunLife 2016-10-02 15:42 采纳率: 0%
浏览 1204

JDBC提示出错问题修改表中数据

一张表 表名mission
number describe 两个字段

以下是修改用到的两处代码
public boolean upd(String sql, String parameters[])
throws ClassNotFoundException, SQLException {
boolean flag=false;
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/users", "root", "070902");
PreparedStatement ps = null;
ps = conn.prepareStatement(sql);
for(int i=0;i<parameters.length;i++){
ps.setString(i+1, parameters[i]);
}
int rs = ps.executeUpdate();
if(rs==1) flag=true;
return flag;
}

    //修改任务
public boolean updMission(Mission mission){
    boolean b=false;
    String sql="update mission set describe=?  where id=?";
    String parameters[] ={mission.getDescribe(),mission.getNumber()+""};
    SqlHelper sp = new SqlHelper();
    try {
         b =sp.upd(sql, parameters);

    } catch (ClassNotFoundException | SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }finally{

    }
    return b;
}

mission是个对象 构造应该没问题  编译通过 运行报错
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'describe='w'  where number='10'' at line 1
我在另外一个地方一模一样的方法 可以修改成功  就是where 后面的条件 
求大神帮忙看下了 刚学 找错好久了
  • 写回答

3条回答 默认 最新

  • devmiao 2016-10-02 15:46
    关注
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料