Commit c26708b6 authored by adwisatya's avatar adwisatya
Browse files

Finalisasi untuk testing

parent cfa03698
......@@ -26,7 +26,7 @@ user.properties.file=C:\\Users\\Muldani\\AppData\\Roaming\\NetBeans\\8.0\\build.
<<<<<<< HEAD
user.properties.file=C:\\Users\\A450LC W8\\AppData\\Roaming\\NetBeans\\8.0.1\\build.properties
=======
user.properties.file=C:\\Users\\A450LC W8\\AppData\\Roaming\\NetBeans\\8.0.1\\build.properties
user.properties.file=C:\\Users\\adwisatya\\AppData\\Roaming\\NetBeans\\8.0.2\\build.properties
>>>>>>> 02323e945e52f7a247d213f954c360232adc5b0e
>>>>>>> 43edd7f388dc28ed09074436ded7167fffce2bcf
>>>>>>> 08b39e9ffc058e8856fd1186a9d3fbe46d951054
......
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<<<<<<< HEAD
<file>file:/C:/Users/adwisatya/Documents/Semester%206/Tugas/IF3230%20Sister/IF3230-Tugas-Besar-Sister-2015/src/client/TheAlchemistClient/src/thealchemist/engine/Connection.java</file>
<file>file:/C:/Users/adwisatya/Documents/Semester%206/Tugas/IF3230%20Sister/IF3230-Tugas-Besar-Sister-2015/src/client/TheAlchemistClient/src/thealchemist/engine/Main.java</file>
=======
<file>file:/D:/Kuliah/Semester%206/Sister%20Final/src/client/TheAlchemistClient/src/thealchemist/gui/ImagePanel.java</file>
<file>file:/D:/Kuliah/Semester%206/Sister%20Final/src/client/TheAlchemistClient/src/thealchemist/gui/AlcTradeItem.java</file>
<file>file:/D:/Kuliah/Semester%206/Sister%20Final/src/client/TheAlchemistClient/src/thealchemist/engine/Connection.java</file>
<file>file:/D:/Kuliah/Semester%206/Sister%20Final/src/client/TheAlchemistClient/src/thealchemist/gui/AlcOffer.java</file>
<file>file:/D:/Kuliah/Semester%206/Sister%20Final/src/client/TheAlchemistClient/src/thealchemist/gui/AlcFindItem.java</file>
<file>file:/D:/Kuliah/Semester%206/Sister%20Final/src/client/TheAlchemistClient/src/thealchemist/gui/AlcMap.java</file>
<file>file:/D:/Kuliah/Semester%206/Sister%20Final/src/client/TheAlchemistClient/src/thealchemist/gui/AlcTradeBox.java</file>
<file>file:/D:/Kuliah/Semester%206/Sister%20Final/src/client/TheAlchemistClient/src/thealchemist/gui/AlcItem.java</file>
<file>file:/D:/Kuliah/Semester%206/Sister%20Final/src/client/TheAlchemistClient/src/thealchemist/gui/AlcMixItem.java</file>
>>>>>>> 77c959b07994efa7fbbb60aa68b2a4651fb2a8bc
</group>
</open-files>
</project-private>
......@@ -25,7 +25,7 @@ user.properties.file=C:\\Users\\Muldani\\AppData\\Roaming\\NetBeans\\8.0\\build.
<<<<<<< HEAD
user.properties.file=C:\\Users\\A450LC W8\\AppData\\Roaming\\NetBeans\\8.0.1\\build.properties
=======
user.properties.file=C:\\Users\\Muldani\\AppData\\Roaming\\NetBeans\\8.0\\build.properties
user.properties.file=C:\\Users\\adwisatya\\AppData\\Roaming\\NetBeans\\8.0.2\\build.properties
>>>>>>> 02323e945e52f7a247d213f954c360232adc5b0e
>>>>>>> 43edd7f388dc28ed09074436ded7167fffce2bcf
>>>>>>> 08b39e9ffc058e8856fd1186a9d3fbe46d951054
......
......@@ -2,15 +2,11 @@
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<<<<<<< HEAD
<group/>
=======
<group>
<file>file:/C:/Users/adwisatya/Documents/Semester%206/Tugas/IF3230%20Sister/IF3230-Tugas-Besar-Sister-2015/src/server/src/thealchemist/Utility.java</file>
<file>file:/C:/Users/adwisatya/Documents/Semester%206/Tugas/IF3230%20Sister/IF3230-Tugas-Besar-Sister-2015/src/server/src/thealchemist/Client.java</file>
<file>file:/C:/Users/adwisatya/Documents/Semester%206/Tugas/IF3230%20Sister/IF3230-Tugas-Besar-Sister-2015/src/server/src/thealchemist/Database.java</file>
<file>file:/C:/Users/adwisatya/Documents/Semester%206/Tugas/IF3230%20Sister/IF3230-Tugas-Besar-Sister-2015/src/server/src/thealchemist/TCPServer.java</file>
</group>
>>>>>>> c8b6477f4c12f5e7eb0ab8b8b349a587b6ef971c
</open-files>
</project-private>
......@@ -64,7 +64,7 @@ public class Client extends Thread{
public ArrayList<String> location = new ArrayList<String>(Arrays.asList("0", "0"));
NetworkInterface networkinterface = NetworkInterface.getByIndex(13);
public ArrayList<Integer> items;
public ArrayList<String> servers;
public ArrayList<String> servers = new ArrayList<String>();
public String offers;
/* External Class */
......@@ -116,7 +116,7 @@ public class Client extends Thread{
public void sendToClient(String tmpStr) throws IOException{
PrintStream out = new PrintStream(connectionSocket.getOutputStream());
out.print(tmpStr);
System.out.println(tmpStr);
System.out.println("Response: "+tmpStr);
}
public void checkCommand(String cmd) throws IOException, NoSuchAlgorithmException, JSONException {
cmdJoin();
......@@ -176,7 +176,7 @@ public class Client extends Thread{
break;
/* 12 - belum di tes*/
case "findoffer":
cmdFindOffer(new Integer(utility.JSONtoString("itemid",cmd)));
cmdFindOffer(new Integer(utility.JSONtoString("item",cmd)));
break;
case "sendaccept":
cmdSendAccept(utility.JSONtoString("token",cmd),utility.JSONtoString("offer_token",cmd));
......@@ -201,8 +201,7 @@ public class Client extends Thread{
for(int i = 0; i<objArr.length();i++){
objArr.getJSONObject(i).get("ip");
objArr.getJSONObject(i).get("port");
System.out.println("objArr.toString()");
servers.add(objArr.toString());
servers.add(objArr.getJSONObject(i).toString());
}
} catch (JSONException ex) {
Logger.getLogger(Client.class.getName()).log(Level.SEVERE, null, ex);
......
......@@ -31,7 +31,27 @@ public class Database {
static final String password = "";
Utility utility = new Utility();
public int initiateInventory(String _username) throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException{
Connection conn = null;
PreparedStatement statement = null;
int rs = 0;
try{
Class.forName(driver);
conn = DriverManager.getConnection(url+dbName,username,password);
statement = conn.prepareStatement("INSERT INTO `inventory` (`token`) VALUES (?);");
try {
statement.setString(1, utility.toMD5(_username));
} catch (NoSuchAlgorithmException ex) {
Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
}
rs = statement.executeUpdate();
statement.close();
conn.close();
}catch(SQLException e){
e.printStackTrace();
}
return rs;
}
public int AddUser(String _username, String _password) throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException{
Connection conn = null;
PreparedStatement statement = null;
......@@ -50,6 +70,7 @@ public class Database {
rs = statement.executeUpdate();
statement.close();
conn.close();
initiateInventory(_username);
}catch(SQLException e){
e.printStackTrace();
}
......
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