First I make a record to the database from a Frame and without leaving the application I enter another Frame where I consult the data but the data that I just entered from the previous Frame does not appear, if I close the program and I'll run it again and enter the Frame of the queries directly if I see the record, this is the code I use to make the query.
try {
DefaultTableModel modelo = new DefaultTableModel();
final JTable table = new JTable(modelo);
TableColumnModel columnModel = table.getColumnModel();
for(int i=0;i<4;i++) {
modelo.addColumn(columnas[i]);
}
columnModel.getColumn(0).setPreferredWidth(70);
columnModel.getColumn(1).setPreferredWidth(120);
columnModel.getColumn(2).setPreferredWidth(30);
columnModel.getColumn(3).setPreferredWidth(30);
DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();
tcr.setHorizontalAlignment(SwingConstants.CENTER);
table.getColumnModel().getColumn(0).setCellRenderer(tcr);
table.getColumnModel().getColumn(1).setCellRenderer(tcr);
table.getColumnModel().getColumn(2).setCellRenderer(tcr);
table.getColumnModel().getColumn(3).setCellRenderer(tcr);
table.setPreferredScrollableViewportSize(new Dimension(400,300));
JScrollPane scrollpane = new JScrollPane(table);
Connection con = getConection();
String sql = "SELECT num_control,Nombre,fecha_inicio,fecha_termino FROM alumno";
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
ResultSetMetaData rsMd = rs.getMetaData();
int cantidadColumnas = rsMd.getColumnCount();
while(rs.next()) {
Object[] filas = new Object[cantidadColumnas];
for(int i=0; i<cantidadColumnas;i++) {
filas[i]=rs.getObject(i+1);
}
modelo.addRow(filas);
}