throw new PersistenceException("Informe o id válido para fazer a busca!");
}
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
Mercadoria m = null;
try {
conn = ConnectionManager.getConnection();
stmt = createStatementWithLog(conn, GET_MERCADORIA_BY_ID);
stmt.setInt(1, id);
rs = stmt.executeQuery();
if (rs.next()) {
String nome = rs.getString("nome");
String descricao = rs.getString("descricao");
int qtde = rs.getInt("quantidade");
double preco = rs.getDouble("preco");
m = new Mercadoria(id, nome, descricao, qtde, preco);
}
return m;
} catch (SQLException e) {
String errorMsg = "Erro ao consultar mercadoria por id!";
log.error(errorMsg, e);