dis = new DataInputStream(csocket.getInputStream());
int choice = dis.readInt();
Connection conn = MySqlConnect.ConnectDB();
PreparedStatement pst = conn.prepareStatement("Select hostname from clients where C_ID=");
ResultSet rs = pst.executeQuery();
如何将选择放入给定的查询?
答案 0 :(得分:1)
您可以尝试使用pst.setInt
,如下所示:
PreparedStatement pst=conn.prepareStatement("Select hostname from clients where C_ID=?");
pst.setInt(1, choice);
ResultSet rs=pst.executeQuery();