0
I made a select in the database in which will make a query according to name, and order it but when executing select happened the following error.
public List<Motoristas> mostrarMotoristasPaginado(int pagina,String ordenacao,String pesquisa){
try {
con = Conecta.conexao();
} catch (ClassNotFoundException ex) {
Logger.getLogger(Conecta.class.getName()).log(Level.SEVERE, null, ex);
}
int limite=3;
int offset=(pagina*limite)-limite;
try {
String sql="Select * from tb_motorista where mo_nome like '%"+pesquisa+"%' order by"+ordenacao+" LIMIT 3 OFFSET"+offset;
Statement statement = con.createStatement();
ResultSet rs = statement.executeQuery(sql);
List lista = new ArrayList();
while(rs.next()){
Motoristas mo= new Motoristas();
mo.setMo_nome((rs.getString("mo_nome")));
mo.setMo_data(rs.getString("mo_data"));
mo.setMo_cpf(rs.getString("mo_cpf"));
mo.setMo_modelo(rs.getString("mo_modelo"));
mo.setMo_status(rs.getString("mo_status"));
mo.setMo_sexo(rs.getString("mo_sexo"));
lista.add(mo);
}
return lista;
} catch (Exception e) {
JOptionPane.showConfirmDialog(null,e);
return null;
}
}