有谁能帮我看看这段代码为什么不能修改数据库里的数据!!!急急急!!!
有谁能帮我看看这段代码为什么不能修改数据库里的数据!!!
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
try{
Connection con = DBControl.connectToDb();
Statement stmt = con.createStatement();
// int a=this.jTable2.getValueAt(jTable2.getSelectedRow(),0));//
stmt.executeUpdate( "exec UPDATE studentmaset( "+this.jTextField4.getText()+ ", "+this.jTextField5.getText()+ ", "+this.jTextField6.getText()+ ", "+this.jTextField1.getText()+ "), "+this.jTable2.getValueAt(jTable2.getSelectedRow(),0));
// System.out.println( "程序运行到此处! ");
this.getData();
this.getNull();
jOptionPane2.showMessageDialog(this, "修改成功! ");
}catch(Exception E){
jOptionPane2.showMessageDialog(this,E.getMessage());
E.printStackTrace();
}
}
==================================================================================
语句
stmt.executeUpdate( "exec UPDATE studentmaset( "+this.jTextField4.getText()+ ", "+this.jTextField5.getText()+ ", "+this.jTextField6.getText()+ ", "+this.jTextField1.getText()+ "), "+this.jTable2.getValueAt(jTable2.getSelectedRow(),0));
到底为什么出错?该怎么修改!
------解决方案--------------------update tableName set coloumName=value,coloumName=value......
------解决方案--------------------UPDATE 表名SET 字段=值
只有字段没有附值啊
把你的语句先去数据库执行一下,能修改了,再改成java语句