所以我正在尝试创建一个更新Java DB中记录的按钮,但每当我点击按钮时,我都会收到此错误,“当前光标位置的操作无效”。我无法弄清楚问题,所以也许有人可以帮助我?我已经为这项工作制作了一个较短的版本,但我无法使这个工作。一些帮助将非常感激。
i = Integer.parseInt(txt_userid.getText( ));
s = txt_pass.getText( );
n = txt_name.getText( );
birthdate = txt_bdate.getText( );
contactno = Integer.parseInt(txt_contact.getText( ));
age = Integer.parseInt(txt_age.getText( ));
email = txt_email.getText( );
address = txt_address.getText( );
gender = txt_gender.getText( );
adult = Integer.parseInt(txt_adult.getText( ));
children = Integer.parseInt(txt_child.getText( ));
seniors = Integer.parseInt(txt_senior.getText( ));
charge = Integer.parseInt(txt_charge.getText( ));
travelclass = txt_travelclass.getText( );
luggage = txt_luggage.getText( );
flightID = txt_flightid.getText( );
departdate = txt_depardate.getText( );
departtime = txt_departime.getText( );
destination = txt_destination.getText( );
arrivdate = txt_arrivdate.getText( );
arrivtime = txt_arrivtime.getText( );
try{
rs.updateInt("USERID",i);
rs.updateString("PASSWORD",s);
rs.updateString("USERNAME",n);
rs.updateInt("AGE",age);
rs.updateString("GENDER",gender);
rs.updateString("BIRTHDATE",birthdate);
rs.updateString("EMAIL",email);
rs.updateInt("CONTACTNO",contactno);
rs.updateString("ADDRESS",address);
rs.updateString("FLIGHTID", flightID);
rs.updateString("DEPARDATE", departdate);
rs.updateString("DEPARTIME", departtime);
rs.updateString("DESTINATION", destination);
rs.updateString("TRAVELCLASS", travelclass);
rs.updateString("LUGGAGE", luggage);
rs.updateInt("TOTALPAY", charge);
rs.updateInt("ADDPASSENGERSSENIOR", seniors);
rs.updateInt("ADDPASSENGERSADULT", adult);
rs.updateInt("ADDPASSENGERSCHILD", children);
rs.updateString("ARRIVALDATE", arrivdate);
rs.updateString("ARRIVALTIME", arrivtime);
rs.updateRow( );
Refresh_RS_STMT();
ShowAll();
JOptionPane.showMessageDialog(AdminWindow.this,
"Record has been saved!");
}catch(SQLException err){
System.out.println(err.getMessage() );
}
错误讯息:
java.sql.SQLException: Invalid operation at current cursor position.
at org.apache.derby.client.am.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.client.am.ClientResultSet.updateInt(Unknown Source)
at org.apache.derby.client.am.ClientResultSet.updateInt(Unknown Source)
at airline_system.AdminWindow.btn_saveActionPerformed(AdminWindow.java:719)
at airline_system.AdminWindow.access$600(AdminWindow.java:5)
at airline_system.AdminWindow$7.actionPerformed(AdminWindow.java:344)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: ERROR XJ121: Invalid operation at current cursor position.
at org.apache.derby.client.am.ClientResultSet.checkUpdatePreconditions(Unknown Source)
... 41 more