Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void actualizartabla(String user) {
- try {
- DefaultTableModel model = new DefaultTableModel();
- jtAsignaciones.setModel(model);
- PreparedStatement ps = null;
- ResultSet rs = null;
- String estatus = "asignado";
- Connection conn = MySQLConection.getConnection();
- String sql = "select idPedidoEmpleado, nombreArreglo,tiempoEstimado,comision"
- + " from pedidosempleado INNER JOIN catalogoarreglos USING (idArreglo)"
- + " where user= '"
- + user
- + "'AND estatus ='"
- + estatus
- + "'";
- ps = conn.prepareStatement(sql);
- rs = ps.executeQuery();
- ResultSetMetaData rsMeta = rs.getMetaData();
- int columnas = rsMeta.getColumnCount();
- model.addColumn("ID");
- model.addColumn("Nombre Arreglo");
- model.addColumn("Tiempo estimado");
- model.addColumn("Comision");
- int[] anchos = {20, 200, 50, 50};
- for (int x = 0; x < columnas; x++) {
- jtAsignaciones.getColumnModel().getColumn(x).setPreferredWidth(anchos[x]);
- }
- while (rs.next()) {
- Object[] filas = new Object[columnas];
- for (int i = 0; i < columnas; i++) {
- filas[i] = rs.getObject(i + 1);
- }
- model.addRow(filas);
- }
- } catch (Exception e) {
- JOptionPane.showMessageDialog(null, "Error al actualizar" + e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment