用于显示可用席位的SQL查询 - Java

时间:2017-08-20 08:40:17

标签: java mysql

我有一个名为user www-data; worker_processes auto; pid /run/nginx.pid; events { worker_connections 2000; multi_accept on; use epoll; } http { upstream backend { server localhost:8080 max_fails=3 fail_timeout=120s; } location /path { proxy_pass http://backend; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Host $server_name; } : : sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; proxy_connect_timeout 1000; proxy_send_timeout 1000; proxy_read_timeout 1000; send_timeout 1000; : : } 的表格,以及表格如何显示

Rooms

在下面的代码中,我可以使用数据库中的房间号填充组合框。但我想要做的是,当我选择一个房间号码时,该房间号码的可用座位必须更新。

例如,当我选择

RoomNumber 4,可用座位4

RoomNumber 3,可用座位2

我怎样才能实现这个目标?

查询

//查询以获取房间号码到组合框

 CREATE TABLE Rooms 
 (
     id INT AUTO_INCREMENT,
     RoomNumber VARCHAR(32) NOT NULL,
     AvailableSeats INT NOT NULL,
     PRIMARY KEY (id)   
 ) 

//查询以获取每个房间号码的相应可用座位

public void FindRoom() {
    String query = "Select * from Rooms";
    try {
        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery(query);
        while(rs.next()) {
            String getRoomNumber = rs.getString("RoomNumber");
            FindRoom.addItem(getRoomNumber);
        }
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null, ex);
    }
}

0 个答案:

没有答案