How to know when nothing is entered from the database into the table? I do my query and the result is entered into the table, but when nothing is entered, it means that the searched name is not in the database. At that time I want to send a message that it is not in the database, just that I do not know how to validate that there is nothing in the Jtable.
private void BuscarNomActionPerformed(java.awt.event.ActionEvent evt) {
String[] titulos = {"NOMBRE","# REPORTE","GRUPO","SISTEMA","FECHA","MOTIVO","SUSPENSION"};
String[] registro = new String[7];
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
Connection unaConexion = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/umaya", "root", "");
java.sql.Statement instruccionSQL = unaConexion.createStatement();
String Nomb=Nombre.getText();
modelo = new DefaultTableModel(null, titulos);
Conexion mysql = new Conexion();
Connection cn = mysql.Conectar();
Statement st;
sSQL = "SELECT nombre,numero_reporte,gradoygrupo,sistema,fecha,motivo,suspension FROM generaldb WHERE nombre LIKE '%"+Nomb+"%'";
String cadena;
Integer co=0;
try {
st = cn.createStatement();
ResultSet rs = st.executeQuery(sSQL);
while (rs.next()) {
String cow = rs.getString("nombre");
//INGRESO EL RESULTADO A MI TABLA
registro[0] = rs.getString("nombre");
registro[1] = rs.getString("numero_reporte");
registro[2] = rs.getString("gradoygrupo");
registro[3] = rs.getString("sistema");
registro[4] = rs.getString("fecha");
registro[5] = rs.getString("motivo");
registro[6] = rs.getString("suspension");
modelo.addRow(registro);
}
Tabla.setModel(modelo);
}
catch (SQLException ex)
{
JOptionPane.showMessageDialog(null, "no se ingreso a la base de datos ");
}
}