I have 1 table in database

TableRoom
- NoRoom
- Status

and i have noroom
101,
102,
103,
104,
105,
201,
202,
203,
204,
205

My problem is how to call a database and specify the colors for the buttons. if the status of the room was filled with the buttons should be colored red, and if the status of the room was empty, the button should be green

JButton [] arr = new JButton[10];

.........

if(r.next()){

status = r.getString("status");

noRoom = r.getString("noRoom");

for(int i=0; i<10; i++){

if (arr[i].getActionCommand().equals(noRoom)){

r.beforeFirst();

while(r.next()){

arr[i].setBackground(Color.red);

}

s.close();

c.close();

} else {

arr[i].setBackground(Color.green);

}

That logic looks suspicious!
Maybe something like this (in pseudocode) would work better

for each row in the result set {
   use the noRoom to find the corresponding button
   if status is "filled" set button red
   else set button green
}