Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- else if (Item == 1)
- { /* Computer List) */
- comboBoxOrderBy.setModel(new DefaultComboBoxModel(new String[] { "computer_id", "cpu_model",
- "cpu_clock", "ram", "hdd", "os", "archit", "computer_name", "computer_type",
- "computer_brand", "computer_model", "serial_number", "status" }));
- comboBoxOrderBy.addActionListener(
- new ActionListener()
- { /*
- * ACÇAO DA CAIXA
- * ORDER BY
- */
- public void actionPerformed(ActionEvent arg0)
- {
- String teste = (String)comboBoxOrderBy.getSelectedItem();
- JOptionPane.showMessageDialog(frmInventoryDatabaseManager, teste);
- try
- {
- /*
- * BEGINING OF DATABASE REQUEST
- */
- Connection lig = DriverManager.getConnection(
- "jdbc:mysql://localhost/inventorydb", "root", "");
- PreparedStatement inst = lig.prepareStatement(
- "SELECT computer_id, cpu_model, cpu_clock, ram, hdd, "
- + "os, archit, computer_name, computer_type, computer_brand, "
- + "computer_model, serial_number, status FROM computerlist ORDER BY ? ASC");
- inst.setString(1, teste);
- ResultSet rs = inst.executeQuery();
- table1.setModel(DbUtils.resultSetToTableModel(rs));
- lig.close();
- /*
- * END OF DATABASE REQUEST
- * SERVICES
- */
- }
- catch (SQLException e1)
- {
- JOptionPane.showMessageDialog(frmInventoryDatabaseManager,
- "Impossivel ligar á base de dados: "
- + e1.getLocalizedMessage());
- }
- }
- });
- }
- suaTable.setAutoCreateRowSorter(true);
Add Comment
Please, Sign In to add comment