File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes rs.updateRow() not working (..) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "rs.updateRow() not working (..) " Watch "rs.updateRow() not working (..) " New topic
Author

rs.updateRow() not working (..)

kstalin babu
Greenhorn

Joined: May 18, 2004
Posts: 7
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.
Slava Imeshev
Greenhorn

Joined: Jun 17, 2004
Posts: 23
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'))


Regards,<br /> <br />Slava Imeshev
 
GeeCON Prague 2014
 
subject: rs.updateRow() not working (..)