How to perform LIKE 'c%'
search with PreparedStatement
?
I have the following code:
PreparedStatement pstm;
ResultSet rs;
public void pesquisarAdministrador(){
String sql = "SELECT administrador.idadministrador, administrador.usr_adm FROM administrador WHERE usr_adm LIKE ?";
try {
pstm = conn.prepareStatement(sql);
pstm.setString(1,"%" + txtId.getText() + "%'");
rs = pstm.executeQuery();
tblAdministrador.setModel(DbUtils.resultSetToTableModel(rs));
} catch (SQLException error) {
JOptionPane.showMessageDialog(null, error);
}
}
But it does not return anything, but when I remove the tables and put *
it's normal.