-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
  • 15,689
  • 25
  • 79
  • 125
zeeshan nisar
  • 553
  • 2
  • 4
  • 18

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,299
  • 4
  • 22
  • 36