问题描述:

I have to build a client/server database; the server builds the database that contains a single table. It has to pass the table to

the client which will display it in a TableView.

The server retrieves the SQL commands from a txt file.

The question is how do I (Server) pass the table that I've created to the client?

I thought of ArrayList but it gets really complicated and hard to handle.

The server code:

//Load driver, connect to JDBC..

 private void DBSetup()

{

try

{

statement = connection.createStatement();

FileInputStream fstream = new FileInputStream("mysql.txt");

// Get the object of DataInputStream

DataInputStream in = new DataInputStream(fstream);

BufferedReader br = new BufferedReader(new InputStreamReader(in));

String strLine;

//Read File Line By Line

while ((strLine = br.readLine()) != null)

{

System.out.println(strLine);

//INSERT PLATFORM->RUNLATER

status.appendText(strLine+"\n");

if (strLine != null && !strLine.equals(""))

statement.execute(strLine);

}

br.close();

}catch (java.lang.Exception ex)

{

Platform.runLater(()->

{

status.setText(ex.toString());

});

}

}

My program supports multiple clients, so I have a hashTable that holds the socket and the outputStream of each client.

P.S.: I'm working with javaFX.

相关阅读:
Top