• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

rs.updateRow() not working (..)

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is the code sample....

private void getActionPerformed(java.awt.event.ActionEvent evt) {
try{
query="select ptscno,ptbcrno,ptprno,trunc(to_date(ptprdt,'dd-mm-yyyy')),ptblamt,ptmisamt,ptmisamtcd,ptreconchg from payment where ptprno="+bcrc_prno.getText();
rs=stmt.executeQuery(query);
if(rs.next())
{
bcrc_scno.setText(rs.getString(1));
bcrc_prno.setText(rs.getString(3));
bcrc_bcrcno.setText(rs.getString(2));
bcrc_prdt.setText(rs.getDate(4).toString());
bcrc_billamt.setText(rs.getString(5));
bcrc_misamt.setText(rs.getString(6));
bcrc_misamtcd.setText(rs.getString(7));
bcrc_reconchg.setText(rs.getString(8));
dissable(true); //user defined function to dissable the text fileds
}
else
{
new opendialog(this,"ERROR MESSAGE ...").show();
bcrc_scno.setText("");
bcrc_bcrcno.setText("");
bcrc_prno.setText("");
bcrc_prdt.setText("");
bcrc_billamt.setText("");
bcrc_misamt.setText("");
bcrc_misamtcd.setText("");
bcrc_reconchg.setText("");
bcrc_prno.requestFocus();
dissable(false);
}

}catch(SQLException p){
System.err.print("SQLException :");
System.err.println(p.getMessage());
try{
con.close();
}catch(SQLException e)
{
System.err.print("SQLException :");
System.err.println(e.getMessage());
}
System.exit(2);
}
}


private void updateActionPerformed(java.awt.event.ActionEvent evt) {
try{

if(bcrc_scno.isEditable())
{
rs.updateString(1, bcrc_scno.getText());
rs.updateString(2, bcrc_bcrcno.getText());
rs.updateString(3, bcrc_prno.getText());
String dt=bcrc_prdt.getText();
java.sql.Date myDate = java.sql.Date.valueOf(dt);
rs.updateDate(4, myDate);
rs.updateString(5, bcrc_billamt.getText());

if(!bcrc_misamt.getText().equals(""))
rs.updateString(6,bcrc_misamt.getText());

if(!bcrc_misamtcd.getText().equals(""))
rs.updateString(7,bcrc_misamtcd.getText());

if(!bcrc_reconchg.getText().equals(""))
rs.updateString(8,bcrc_reconchg.getText());

rs.updateRow();

con.commit();
bcrc_scno.setText("");
bcrc_bcrcno.setText("");
bcrc_prno.setText("");
bcrc_prdt.setText("");
bcrc_billamt.setText("");
bcrc_misamt.setText("");
bcrc_misamtcd.setText("");
bcrc_reconchg.setText("");
bcrc_prno.requestFocus();
dissable(false);
}
else
{
new opendialog(this,"ERROR MESSAGE ...").show();
bcrc_scno.setText("");
bcrc_bcrcno.setText("");
bcrc_prno.setText("");
bcrc_prdt.setText("");
bcrc_billamt.setText("");
bcrc_misamt.setText("");
bcrc_misamtcd.setText("");
bcrc_reconchg.setText("");
bcrc_prno.requestFocus();
dissable(false);
}
}catch(SQLException p){
System.err.print("SQLException :");
System.err.println(p.getMessage());
try{
con.close();
}catch(SQLException e)
{
System.err.print("SQLException :");
System.err.println(e.getMessage());
}
System.exit(2);
}
}

the idea is to get the data and update it again

getActionPerformed is executed where get button is clicked that will get the data
and updateActionPerformed is executed when update button is clicked that will update the data

the problem is after i get the data from database and put it on some textfields and change some text and then click update button i am getting this error
SQLException RA-00927: missing equal sign

i am unable to figure out kindly help.
thanq in advance

stalin.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure that it would work at all: you result set field #4 is a computed value. I doubt a server would be able to parse back this computation:

select ptscno,ptbcrno,ptprno,trunc(to_date(ptprdt,'dd-mm-yyyy'))
 
These are the worst of times and these are the best of times. And this is the best tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic