if(isource == txtFirstname){
                try{
                   String searchHotelCustomer = "Select * from HotelCustomer where CUSFirstName='"+CUSFirstName+"'";
                   driver.selectQuery(searchHotelCustomer);
                   ResultSet rsSearch = driver.rs;



if(rsSearch.next()){


 txtRoomNum.setText(rsSearch.getString("RoomNumber"));


}


}

how do i get int value from text?

Recommended Answers

All 5 Replies

Integer.valueOf(text)

how?
txtRoomNum.setText(rsSearch.Integer.valueOf("RoomNumber"));

That's not the question you asked. To get int value from text you can use
int i = Integer.valueOf(text);

Your latest code is trying to convert a String to int then convert that back to String for a setTExt. Why?

im trying to get int value from my database.. and then return it to string in textfield

If I understand you correctly you could do something like the following:

final Sting roomNumberString = "2";
final int roomNumber = Integer.parseInt(roomNumberString);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.