Интегрирование подсистем "Деканат" и "Финансы" на программном и информационном уровне, организация передачи данных по личным делам студентов из подсистемы «Деканат» в подсистему «Финансы», страница 6

            String[][] arr = DBFReader.getTable(rs);

            String[] names = new String[colums];

            for (int i = 0; i < colums; i++) {

                names[i] = rsmd.getColumnName(i + 1);

            }

            TableModel model = new DefaultTableModel(arr, names);

            jTable1.setModel(model);

        } catch (SQLException ex) {

            Logger.getLogger(DBViewer.class.getName()).log(Level.SEVERE, null, ex);

        }

    }                          

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        

        myDB = new DBManager();

        jButton3.setEnabled(true);

        jButton4.setEnabled(true);

    }                                       

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                        

        try {

            ResultSet rs = myDB.executeQuery("SELECT * FROM CONTINGENTS");

            ResultSetMetaData rsmd = rs.getMetaData();

            int colums = rsmd.getColumnCount();

            String[][] arr = DBFReader.getTable(rs);

            String[] names = new String[colums];

            for (int i = 0; i < colums; i++) {

                names[i] = rsmd.getColumnName(i + 1);

            }

            TableModel model = new DefaultTableModel(arr, names);

            jTable1.setModel(model);

        } catch (SQLException ex) {

            Logger.getLogger(DBViewer.class.getName()).log(Level.SEVERE, null, ex);

        }

    }                                       

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                         

        try {

            String choise = jComboBox1.getSelectedItem().toString();

            String str;

            if (choise.equals("Все группы")) {

                    str = "select C.NUM_ZACH, C.FAM, C.IMJA, C.OT, C.DATA_ROJD, "

                            + "C.NAL_KOD, C.K_FAK, C.KOD_SPEC, "

                            + "G.NAIM, C.K_KURS from contingent C "

                            + "JOIN  facultet F ON C.K_FAK = F.KOD "

                            + "join  spec S ON C.KOD_SPEC = S.KOD_SPEC "

                            + "join group G ON C.K_GRUP = G.KOD";

                } else {

                    str = "select C.NUM_ZACH, C.FAM, C.IMJA, C.OT, C.DATA_ROJD, "

                            + "C.NAL_KOD, C.K_FAK, C.KOD_SPEC, "

                            + "G.NAIM, C.K_KURS from contingent C "

                            + "JOIN  facultet F ON C.K_FAK = F.KOD "

                            + "join  spec S ON C.KOD_SPEC = S.KOD_SPEC "

                            + "join group G ON C.K_GRUP = G.KOD and G.NAIM='" + choise + "'";

                }

            ResultSet rs = DBFReader.executeQuery(conn, str);

            String[][] arr = DBFReader.getTable(rs);

            int[] res = myDB.addNewStudent(arr);

            String stat = "Добавлено:" + res[0]

                    + "\r\nОбновлено:" + res[1]

                    + "\r\nПовреждено:" + res[2];

            JOptionPane.showMessageDialog(null, stat, "Результаты добавления.", WIDTH);

        } catch (ParseException ex) {

            Logger.getLogger(DBViewer.class.getName()).log(Level.SEVERE, null, ex);

        } catch (SQLException ex) {

            Logger.getLogger(DBViewer.class.getName()).log(Level.SEVERE, null, ex);

        }

    }