a
This commit is contained in:
1 parent
4fbf553956
commit
964b1b7308
2 files changed
+10
-28
No files matched your search
+9
-27
@@ -53,7 +53,7 @@ public class Client {
|
|||||||
|
|
||||||
private static void setupConnection() throws IOException {
|
private static void setupConnection() throws IOException {
|
||||||
String ip = "localhost";
|
String ip = "localhost";
|
||||||
int port = 8888;
|
int port = 9999;
|
||||||
socket = new Socket(ip, port);
|
socket = new Socket(ip, port);
|
||||||
buf = new BufferedReader(new InputStreamReader(socket.getInputStream(), "utf-8"));
|
buf = new BufferedReader(new InputStreamReader(socket.getInputStream(), "utf-8"));
|
||||||
write = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), "utf-8"), true);
|
write = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), "utf-8"), true);
|
||||||
@@ -79,7 +79,10 @@ public class Client {
|
|||||||
update();
|
update();
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
export();
|
ExportToCSV.to("output.csv", "select * from book");
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
ExportToXLS.to("select * from book", "output.xls");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -93,8 +96,7 @@ public class Client {
|
|||||||
try {
|
try {
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("code", 8);
|
map.put("code", 8);
|
||||||
if (write != null)
|
write.println(new Gson().toJson(map));
|
||||||
write.println(new Gson().toJson(map));
|
|
||||||
if (socket != null)
|
if (socket != null)
|
||||||
socket.close();
|
socket.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -142,8 +144,9 @@ public class Client {
|
|||||||
System.out.println("3. Querying library data;");
|
System.out.println("3. Querying library data;");
|
||||||
System.out.println("4. Deleting library data;");
|
System.out.println("4. Deleting library data;");
|
||||||
System.out.println("5. Modifying library data;");
|
System.out.println("5. Modifying library data;");
|
||||||
System.out.println("6. Exporting library data;");
|
System.out.println("6. Exporting library data to a CSV file;");
|
||||||
System.out.println("7. Exiting Assistant.");
|
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):");
|
System.out.println("Please enter options (1-8):");
|
||||||
int choose = scan.nextInt();
|
int choose = scan.nextInt();
|
||||||
scan.nextLine();
|
scan.nextLine();
|
||||||
@@ -330,25 +333,4 @@ public class Client {
|
|||||||
System.out.println("No record found to update price!");
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@ import java.net.Socket;
|
|||||||
import server.thread.HandleThread;
|
import server.thread.HandleThread;
|
||||||
|
|
||||||
public class Server {
|
public class Server {
|
||||||
private static final int PORT = 8888;
|
private static final int PORT = 9999;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
try (ServerSocket server = new ServerSocket(PORT)) {
|
try (ServerSocket server = new ServerSocket(PORT)) {
|
||||||
|
|||||||
Reference in new issue
Block a user