This is a simple code print some rows from a Database. but When I execute this nothing is print on screen. I figured that the problem is rs.next()
method is ski
No no need to use :
if (rs.next()) {
The while is enough, this make the result two times. instead you can use :
boolean b = false;
while (rs.next()) {
b = true;
...
}
if(!b) {
JOptionPane.showMessageDialog(null, "Not Found");
}
You have to use PreparedStatement instead, to avoid any SQL Injection or syntax error.