Pesquisar parte do nome no Jsp (Firebird)

3 respostas
E

<%@page contentType=“text/html”%>
<%@page pageEncoding=“UTF-8”%>

<%@
include file=“ServerConfiguration.jsp”
%>

<%@
page import=“org.firebirdsql.jdbc.,org.firebirdsql.logging.Logger,java.sql.
%>

<%

Class.forName(“org.firebirdsql.jdbc.FBDriver”);

Connection aConnection = DriverManager.getConnection(DatabaseAddr,UserName, Password);

Statement stmt = aConnection.createStatement();

String Sql=“Select * from clientes”;
ResultSet aQuery=stmt.executeQuery(Sql);

%>

<%–
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library… action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
–%>
<%–
<%@taglib uri=“http://java.sun.com/jsp/jstl/core” prefix=“c”%>
–%>

JSP Page
<h1>Selecionar por nome</h1>

<input type="text" name="vlr" value="" />
<%

while (aQuery.next())

{

%>


<%=aQuery.getString("nome")%>

<%

}
%>

<%--
This example uses JSTL, uncomment the taglib directive above.
To test, display the page like this: index.jsp?sayHello=true&name=Murphy
--%>
<%--
<c:if test="${param.sayHello}">
    <!-- Let's welcome the user ${param.name} -->
    Hello ${param.name}!
</c:if>
--%>

</body>

Esta mostrando todos os registros, ok…mas gostaria de pesquisar parte do nome por exemplo como eu posso fazer isso??

Evandro

3 Respostas

luis.soares

Evandro, seja mais objetivo, cara. Coloca o bloco de código onde você está com dúvida, e qual é exatamente sua necessidade. Se não fica complicado de entender.
Mas pelo que pude entender, hoje vc faz um “Selecy * from …”. Você quer trazer só registros que atendem um critério, por exemplo nome, é isso ?

Abraço.

E

isso…quero fazer o seguinte:
Tenho o Text e quero pesquisar todos os usuario que existe as iniciais daquele text

tipo assim:

select * from clientes where nome like ‘teste%’

gostaria de fazer isso

flw

Evandro

luis.soares

Evandro, você pode fazer assim :

{
...
PreparedStatement stmt = conexao.prepareStatement("Select * from Clientes Where nome like % ? %"); // o "?" representa um parâmetro

stmt.setString(1, nome); //seta valor para parâmetro

stmt.Execute(); // executa o comando

...
}

Abraço !

Criado 10 de novembro de 2006
Ultima resposta 10 de nov. de 2006
Respostas 3
Participantes 2