当前位置: 代码迷 >> Java相关 >> 这段程序错哪了?为什么能运行却无法更新数据
  详细解决方案

这段程序错哪了?为什么能运行却无法更新数据

热度:8526   发布时间:2013-02-25 21:51:06.0
这段程序哪里错了?为什么能运行却无法更新数据?
程序如下:
public void jButton1_actionPerformed(ActionEvent e) {
   
  try{
  if ((jTextField1.getText()!= null)&&(jTextField2.getText()!= null)&&(jTextField3.getText()!= null)){
  Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://COMPUTERBELONGS:1433;DatabaseName=jjtz ","sa", "sa");
  //Statement toUpdate=con.createStatement();
  con.setAutoCommit(false);
  getUpdate.addBatch("update xmmchnfb set xmmch=" +
  jTextField1.getText() + "where ID=" + 1);
  getUpdate.addBatch("update xmmchnfb set qshnf=" +
  jTextField2.getText() + "where ID=" + 1);
  getUpdate.addBatch("update xmmchnfb set zhzhnf=" +
  jTextField3.getText() + "where ID=" + 1);

  getUpdate.executeBatch();
  con.commit();
  con.setAutoCommit(true);

   
  } 
  }
  catch(SQLException ee){
  //System.out.print("系统或者输进数据错误!"+ex.toString());
  }
  Frame2 frame = new Frame2();
  Dimension screenSize = Toolkit.getDefaultToolkit().
  getScreenSize();
  Dimension frameSize = frame.getSize();
  if (frameSize.height > screenSize.height) {
  frameSize.height = screenSize.height;
  }
  if (frameSize.width > screenSize.width) {
  frameSize.width = screenSize.width;
  }
  frame.setLocation((screenSize.width - frameSize.width) / 2,
  (screenSize.height - frameSize.height) / 2);
  frame.setVisible(true);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  this.setVisible(false);
}

------解决方案--------------------------------------------------------
  相关解决方案