Commit d87a3082 authored by adwisatya's avatar adwisatya
Browse files

Tradebox OK

parent c56f8d8e
......@@ -123,6 +123,7 @@ public class Client extends Thread{
case "offer" :
cmdOffer(JSONtoString("token",cmd), Integer.parseInt(JSONtoString("offered_item",cmd)), Integer.parseInt(JSONtoString("n1",cmd)), Integer.parseInt(JSONtoString("demanded_item",cmd)), Integer.parseInt(JSONtoString("n2",cmd)));
break;
/* 10 */
case "tradebox":
cmdTradebox(JSONtoString("token",cmd));
break;
......@@ -322,12 +323,8 @@ public class Client extends Thread{
JSONObject obj = new JSONObject();
try {
JSONArray offersArray = database.TradeBox(token);
if(offersArray.isNull(0)){ // masih bingung if statement ny apa
obj.put("status", "ok");
obj.put("offers",offersArray);
}else{
obj.put("status", "error");
}
obj.put("status", "ok");
obj.put("offers",offersArray);
} catch (ClassNotFoundException ex) {
obj.put("status", "error");
Logger.getLogger(Client.class.getName()).log(Level.SEVERE, null, ex);
......
......@@ -463,7 +463,7 @@ public class Database {
Class.forName(driver);
conn = DriverManager.getConnection(url+dbName,username,password);
statement = conn.createStatement();
rs = statement.executeQuery("SELECT `id_offer`, `offered_item`, `n1`, `demanded_item`, `n2`, `available` FROM `offers` WHERE `token`='"+_token+"'");
rs = statement.executeQuery("SELECT `id_offer`, `offered_item`, `n1`, `demanded_item`, `n2`, `available`,`offer_token` FROM `offers` WHERE `token`='"+_token+"'");
while(rs.next()){
data.put(rs.getString("offered_item"));
data.put(rs.getString("n1"));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment