注册 登录
编程论坛 J2EE论坛

请教一下PreparedStatement的问题,在线等~~~

goopoolzl 发布于 2008-08-15 10:19, 984 次点击
请教一下PreparedStatement的问题,在线等~~~

我写了一个更新数据库的方法
public static void updatepiaoshu()
{
      Connection con=null;
      PreparedStatement pstmt=null;

      try
      {
          con=ConectionFactory.getConnection();  //写了一个连接工厂
          pstmt=con.prepareStatement("update candidates set quantity=quantity+1 where candidateId=?");
          pstmt.setInt(1,1);   
          pstmt.executeUpdate();
      }catch(SQLException se)
       {System.out.println(se.getMessage());}
     finally
    {
          ConnectionFactory.closePrepareStatement(pstmt);
          ConnectionFactory.closeConnection(con);   
    }
}

总是显示无效的列索引~~~ ,请高手指点!!!!!!!!!
2 回复
#2
gankailan2008-08-15 12:05
回复 1# goopoolzl 的帖子
sb,肯定是你的字段名写错了!
#3
恋轩念伊人2008-08-16 16:15
我觉得也可能是上面的原因
1