wood burning stoves 2.0
The moose likes JDBC and Relational Databases and the fly likes problem in deleting data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "problem in deleting data" Watch "problem in deleting data" New topic

problem in deleting data

harsimran kochar

Joined: Sep 09, 2011
Posts: 14
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

Joined: Oct 14, 2005
Posts: 19973

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.
I agree. Here's the link: http://aspose.com/file-tools
subject: problem in deleting data
It's not a secret anymore!