Boa tarde, estou realizando uma consulta ao banco passando um paramentro, porém o retorno da query é null. A conexão está Ok.
Segue trecho do código da classe CelularDAO
public Celular buscar(Celular celular)
{
String sql = "SELECT * FROM celular WHERE price=?";
Celular retorno;
retorno = null;
PreparedStatement pst = Conexao.getPreparedStatement(sql);
try {
pst.setString(1, celular.getPrice());
ResultSet res = pst.executeQuery();
if(res.next())
{
retorno = new Celular();
retorno.setPrice(res.getString("price"));
retorno.setModel(res.getString("model"));
retorno.setBrand(res.getString("brand"));
retorno.setPhotocel(res.getString("photocel"));
retorno.setDate(res.getString("date"));
retorno.setCode(res.getString("code"));
}else {
//se os dados não existirem no Bamco de Dados ele exibibe a mensagem de erro!
System.out.println(“Dados incorretos!”);
}
} catch (SQLException ex) {
Logger.getLogger(CelularDAO.class.getName()).log(Level.SEVERE, null, ex);
}
Trecho da classe Mobile
<a class="mention" href="/u/get">@GET</a>
@Produces(MediaType.APPLICATION_JSON)
<a class="mention" href="/u/path">@Path</a>(“Celular/get/{price}”)
public String getCelular(@PathParam(“price”) String price)
{
Celular c = new Celular();
c.setPrice(price);
CelularDAO dao = new CelularDAO();
c = dao.buscar(c);
Por favor, preciso de help!
