将表传递给客户端

时间:2015-02-20 19:57:35

标签: jdbc javafx client-server javafx-2

我必须建立一个客户端/服务器数据库;服务器构建包含单个表的数据库。它必须通过表格 客户端将在TableView中显示它。 服务器从txt文件中检索SQL命令。 问题是我如何(服务器)将我创建的表传递给客户端? 我想到了ArrayList但它变得非常复杂且难以处理。 服务器代码:

//加载驱动程序,连接到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());
            });
        }

  }

我的程序支持多个客户端,所以我有一个hashTable,它包含每个客户端的套接字和outputStream。 P.S。:我正在使用javaFX。

0 个答案:

没有答案