来自Unix输出的Jtable的人口

时间:2014-10-13 11:00:49

标签: java swing jtable

请帮助,

我正在尝试从UNIX框的输出填充Jtable,我正在通过shell执行hive sql并能够以字符串格式查看输出。我试图以表格格式看到以下输出。

private void jButton1_actionPerformed() {
    if (textarea1.getText() == null || textarea1.getText().equals("")) {
        JOptionPane.showMessageDialog(contentPane,"Please Enter Your Sql."); }
        else {
    String cmd = "/opt/ibm/biginsights/hive/bin/hive -e 'SET hive.cli.print.header=true; " + textarea1.getText() + "'";
    i=0;
    String sql =HiveJdbcClient;
    if (cmd != null) {

        int returnchannel = UnixConnection.getUnixChannel(
                UnixConnection.session, cmd);
        System.out.println("Return Status=" + returnchannel);
        if (returnchannel == 0) {
            resultPanel.removeAll();
            resultPanel.updateUI();
            resultPanel.add(scrollpane, 0);
            BufferedReader bf = null;
            StringBuffer sb = new StringBuffer();
            String line;
            rs = UnixConnection.getUnixChannel(UnixConnection.session, cmd)
            try {
                bf = new BufferedReader(new InputStreamReader(
                        UnixConnection.in));
                while ((line = bf.readLine()) != null) {
                    System.out.println("Return value=" + line);
                    sb.append(line + "\n");
                    rs [i] = sb;
                    i++;

                }
                System.out.println(sb);
                contentPane.updateUI();

            } catch (Exception ex) {
                System.out.println(ex);
            }
            //JTable table = new JTable(DbUtils.resultSetToTableModel(rs));
            table.setTableHeader(null);

        }
    }
        }
}

0 个答案:

没有答案