wood burning stoves 2.0*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "incompatible types" Watch "incompatible types" New topic
Author

incompatible types

Mayura Hayat
Greenhorn

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

code:



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

Joined: Oct 02, 2003
Posts: 11153
    
  16

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
Greenhorn

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: http://aspose.com/file-tools
 
subject: incompatible types
 
Similar Threads
Incompatible type issue
Unable to initialize two dimensional array in for loop
ResultSet to Array
Issue with reversing a string
Recursive anagram problem