Bom dia,
estou desenvolvendo um sistema de busca, onde eu tenho 3 opçoes, buscar por id, nome, processo. A busca por id, tudo tranquilo, já a busca por nome e por processo que esta dando esse erro:
22/07/2011 09:46:34 javax.faces.event.MethodExpressionActionListener processAction
GRAVE: 'java.sql.SQLException' recebido ao invocar escuta de ação '#{manifestacaoBean.pesqBasica}' para o componente 'j_idt27'
22/07/2011 09:46:34 javax.faces.event.MethodExpressionActionListener processAction
GRAVE: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
at com.mysql.jdbc.PreparedStatement.checkBounds(PreparedStatement.java:3717)
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3701)
at com.mysql.jdbc.PreparedStatement.setString(PreparedStatement.java:4552)
at com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:3956)
at Dao.DAO.executeQuery(DAO.java:44)
at Dao.PesquisaDAO.getFindByNOME(PesquisaDAO.java:31)
......
22/07/2011 09:46:34 com.sun.faces.context.ExceptionHandlerImpl log
GRAVE: JSF1073: javax.faces.event.AbortProcessingException obtido durante o processamento de INVOKE_APPLICATION 5: UIComponent-ClientId=formBusca:j_idt27, Message=java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
22/07/2011 09:46:34 com.sun.faces.context.ExceptionHandlerImpl log
GRAVE: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
javax.faces.event.AbortProcessingException: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
........
Caused by: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
at com.mysql.jdbc.PreparedStatement.checkBounds(PreparedStatement.java:3717)
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3701)
at com.mysql.jdbc.PreparedStatement.setString(PreparedStatement.java:4552)
at com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:3956)
at Dao.DAO.executeQuery(DAO.java:44)
at Dao.PesquisaDAO.getFindByNOME(PesquisaDAO.java:31)
at Bean.ManifestacaoBean.pesqBasica(ManifestacaoBean.java:194)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.el.parser.AstValue.invoke(AstValue.java:262)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:153)
... 28 more
codigo do meu Bean:
public List<Manifestacao> pesqBasica() throws ClassNotFoundException, SQLException {
if (!"".equals(id)) {
manifests = pdao.getFindByID(id);
}
if (!"".equals(nome)) {
manifests = pdao.getFindByNOME(nome);
}
/*
if (!"".equals(processo)) {
pesqBasica = pdao.getFindByPROCESSO(processo);
}
*/
return manifests;
}
Codigo do Dao:
//METODO PARA DE BUSCA SIMPLES - ID
public List<Manifestacao> getFindByID(String s) throws SQLException {
String SQL = "SELECT * FROM Ouvidoria.Manifestacao WHERE id = ?";
ResultSet rs = executeQuery(SQL, s);
List<Manifestacao> toReturn = new LinkedList<Manifestacao>();
while (rs.next()) {
toReturn.add(populate(rs));
}
rs.close();
return toReturn;
}
//METODO PARA DE BUSCA SIMPLES - NOME
public List<Manifestacao> getFindByNOME(String s) throws SQLException {
String SQL = "SELECT * FROM Ouvidoria.Manifestacao WHERE nome LIKE LOWER('%?%')";
ResultSet rs = executeQuery(SQL, s);
List<Manifestacao> toReturn = new LinkedList<Manifestacao>();
while (rs.next()) {
toReturn.add(populate(rs));
}
rs.close();
return toReturn;
}
//METODO PARA DE BUSCA SIMPLES - PROCESSO
public List<Manifestacao> getFindByPROCESSO(String s) throws SQLException {
String SQL = "SELECT * FROM Ouvidoria.Manifestacao WHERE processo LIKE LOWER('%?%')";
ResultSet rs = executeQuery(SQL, s);
List<Manifestacao> toReturn = new LinkedList<Manifestacao>();
while (rs.next()) {
toReturn.add(populate(rs));
}
rs.close();
return toReturn;
}
Codigo HTML do form da busca.
<h:outputLabel value="Código:" /> <p:inputText label="id" value="#{manifestacaoBean.id}" maxlength="14" size="18" />
<h:outputLabel value="Nome :" /> <p:inputText label="nome" value="#{manifestacaoBean.nome}" maxlength="14" size="30" />
<h:outputLabel value="Número:" /> <p:inputText label="processo" value="#{manifestacaoBean.processo}" maxlength="14" size="30" />
<p:commandButton value="Buscar" actionListener="#{manifestacaoBean.pesqBasica}" update="formResult, formBusca" ajax="false" />
Alguem poderia me ajudar a solucionar este erro? Não estou conseguindo enteder esta linha que da o erro: GRAVE: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0)., sendo que a função ela esta parametrizada sim.
Alguem pode me ajudar ???