File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes incompatible types Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "incompatible types" Watch "incompatible types" New topic

incompatible types

Mayura Hayat

Joined: Dec 24, 2012
Posts: 11
hello i am trying to take value from textbox and convert it into integer.
i have used the code that is mentioned in this thread but i am receiving an error as incompatible types


can you tel me where i am going wrong?
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11955

I have split your post into its own thread. It's better to create your own original one than to hijack a five year old one.

Also, it's a good idea to post the full and complete error message. It is probably telling you exactly what is wrong. on line 6 of your code, you have an integer ARRAY on the left side, and an int on the right side. you can't do that.

if you just want the value, then take out the "[]"

int psage = Integer.parseInt(sl[i]);

if you need to store more than one and really do need the array, you need to a) first declare the array outside the loop with a size, and b) indicate which slot in the array you want to store your int.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Mayura Hayat

Joined: Dec 24, 2012
Posts: 11
Fred thank you very much ....your reply made me think once again over my block of code and i got my mistake.

the error was in line 6 as pointed by you.
Now i am able to insert the data into the database.
i would like to share the code that will help to insert multiple rows into the database using textboxes with same names i.e txtpsngrnm,psngrsex,psngrage are the names of the textboxes.

stmt.executeQuery("insert into fbook(fbid,fpname,fpage,fpgender) values('"+j+"','"+pname[j] +"','"+psage[j]+"','"+pgender[j]+"')");

Thank You All for your help
I agree. Here's the link:
subject: incompatible types
jQuery in Action, 3rd edition