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
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘