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

public class DBViewer extends javax.swing.JFrame {

    private DBManager myDB = null;

    private Connection conn = null;

    public DBViewer() {

        initComponents();

    }

@SuppressWarnings("unchecked")

private void dataBaseConnect(java.awt.event.MouseEvent evt) {                                

        try {

            conn = DBFReader.getConnection();

            String str = "select * from contingent C "

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

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

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

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

            ResultSet groups = DBFReader.executeQuery(conn, "SELECT DISTINCT G.naim FROM group "

                    + "G,contingent C where C.K_GRUP = G.KOD");

            String[][] gr = DBFReader.getTable(groups);

            String[] gro = new String[gr.length + 1];

            gro[0] = "Все группы";

            for (int i = 0; i < gr.length; i++) {

                gro[i + 1] = gr[i][0];

            }

            DefaultComboBoxModel dcbm = new DefaultComboBoxModel(gro);

            jComboBox1.setModel(dcbm);

            ResultSetMetaData rsmd = rs.getMetaData();

            int colums = rsmd.getColumnCount();

            String[] names = new String[colums];

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

            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 formCreate(java.awt.event.WindowEvent evt) {                            

        // TODO add your handling code here:

        jTable1.setModel(new DefaultTableModel(new Object[0][0], new String[0]));

    }                          

    private void changeCarret(java.awt.event.InputMethodEvent evt) {                             

        // TODO add your handling code here:

    }                            

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

        // TODO add your handling code here:

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

        try {

            Connection conn = DBFReader.getConnection();

            String str = "";

            String str2 = "";

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

                str = "select * from contingent C "

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

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

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

            } else {

                str = "select * from contingent C "

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

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

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

            }

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

            ResultSetMetaData rsmd = rs.getMetaData();

            int colums = rsmd.getColumnCount();