diff --git a/src/client/Client.java b/src/client/Client.java index 5519241..7ee2052 100644 --- a/src/client/Client.java +++ b/src/client/Client.java @@ -53,7 +53,7 @@ public class Client { private static void setupConnection() throws IOException { String ip = "localhost"; - int port = 8888; + int port = 9999; socket = new Socket(ip, port); buf = new BufferedReader(new InputStreamReader(socket.getInputStream(), "utf-8")); write = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), "utf-8"), true); @@ -79,7 +79,10 @@ public class Client { update(); break; case 6: - export(); + ExportToCSV.to("output.csv", "select * from book"); + break; + case 7: + ExportToXLS.to("select * from book", "output.xls"); break; default: break; @@ -93,8 +96,7 @@ public class Client { try { Map map = new HashMap<>(); map.put("code", 8); - if (write != null) - write.println(new Gson().toJson(map)); + write.println(new Gson().toJson(map)); if (socket != null) socket.close(); } catch (Exception e) { @@ -142,8 +144,9 @@ public class Client { System.out.println("3. Querying library data;"); System.out.println("4. Deleting library data;"); System.out.println("5. Modifying library data;"); - System.out.println("6. Exporting library data;"); - System.out.println("7. Exiting Assistant."); + System.out.println("6. Exporting library data to a CSV file;"); + System.out.println("7. Exporting library data to an XLS file;"); + System.out.println("8. Exiting Assistant."); System.out.println("Please enter options (1-8):"); int choose = scan.nextInt(); scan.nextLine(); @@ -330,25 +333,4 @@ public class Client { System.out.println("No record found to update price!"); } } - - private static void export() { - System.out.println("====== Exporting library data ======="); - System.out.println("1. Exporting to CSV file;"); - System.out.println("2. Exporting to XLS file;"); - System.out.println("3. Return to previous menu."); - System.out.println("Please enter options (1-3):"); - int choice = scan.nextInt(); - scan.nextLine(); - switch (choice) { - case 1: - ExportToCSV.to("output.csv", "SELECT * FROM book"); - break; - case 2: - ExportToXLS.to("SELECT * FROM book", "output.xls"); - break; - default: - System.out.println("Returning to previous menu."); - break; - } - } } diff --git a/src/server/Server.java b/src/server/Server.java index d7d8f0d..a04911b 100644 --- a/src/server/Server.java +++ b/src/server/Server.java @@ -6,7 +6,7 @@ import java.net.Socket; import server.thread.HandleThread; public class Server { - private static final int PORT = 8888; + private static final int PORT = 9999; public static void main(String[] args) { try (ServerSocket server = new ServerSocket(PORT)) {