File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in deleting data

 
harsimran kochar
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i click on delete button following exception is generated
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at MyFrame.actionPerformed(AcctHld.java:226)

code of my delete button is

and when i use integer.parseint instead of typecasting into integer then i get a error
symbol : method parseInt(java.lang.Object)
location: class java.lang.Integer
int accountno=(Integer.parseInt(mAccthld.getValueAt(tAcctHld.getSelectedRow(),0)));
^
 
Paul Clapham
Sheriff
Pie
Posts: 20166
24
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the error occurs at this line of code?


And you classify that as a JDBC problem because later in the method there's some JDBC code? Well, anyway, apart from looking in the wrong place for the problem, all that means is that the getValueAt() method doesn't return an Integer object, so you can't cast it to an Integer.

And your proposed fix doesn't compile because getValueAt is declared to return an Object. If you want to use it as a String -- which it is, as you know -- then you need to cast it to String before passing it to the parseInt method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic