-3
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();

How can I put choice into the given query?

dur
  • 14,335
  • 22
  • 74
  • 113
zeeshan nisar
  • 543
  • 2
  • 4
  • 17

1 Answers1

1

You can try to use pst.setInt like this:

 PreparedStatement pst=conn.prepareStatement("Select hostname from clients where C_ID=?");
 pst.setInt(1, choice);
 ResultSet rs=pst.executeQuery();
Abdelhak
  • 8,257
  • 4
  • 21
  • 35