Boa tarde pessoal to com duvida de como refinar uma select com a clausula where…
Por exemplo tenho um formulario que enviar as condições para um segundo formulario…tipo codigo mes e ano…
O segundo formulario deve receber estes dados e usar como condição…
segue meus codigos primeiro o formulario onde coloco as condições, em segundo o formulario que deve receber as condições…[code]<%–
Document : consulta
–%>
<%@page contentType=“text/html” pageEncoding=“UTF-8”%>
formulario de consultaAqui faço o select como vcs podem ver o select e feito direto sem a where pois ja tentei varias forma e não da certo, não sei como pegar os dados do primeiro formulario e usar na condição where.Agradeço a atenção de todos!!
<%--
Document : ipesquisa --%>
<%@page language="java"contentType="text/html; "pageEncoding="UTF-8"import="java.sql.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/xhtm11/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>FOLHA CENTRAL</title>
</head>
<body>
<table border="1">
<thead>
<tr>
<form name="form1" action="formInserindoDados.jsp" target="_blank" method="post">
<input type="submit" value="novo processo" align="center">
</form>
<th>EMPRESA</th><TH>FUNCIONARIO</TH>
<th>NOME</th><th>MÊS</th><th>ANO</th>
<th>EVENTO</th><th>VALOR_EVENTO</th>
<th>VALOR_TOTAL</th>
<th>EXCLUIR</th><th>Atualizar</th>
</tr>
</thead>
<tbody>
<%
Connection conn = null;
Statement st = null;
ResultSet rs = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/central","root","virtual");
st = conn.createStatement();
out.println("Base de dados de Disponivel neste momento");
rs = st.executeQuery("select empresa, funcionario, nome, mes, ano, evento, valor, valfim from func where funcionario=88717 and ano=2009 and mes=2");
while(rs.next()){
%>
<form action="formInserindoDados.jsp" method="post">
<tr><td><%= rs.getString("empresa")%></td>
<td><%= rs.getString("funcionario") %></td>
<td><%= rs.getString("nome") %></td>
<td><%= rs.getString("mes") %></td>
<td><%= rs.getString("ano") %></td>
<td><%= rs.getString("evento") %></td>
<td><%= rs.getString("valor") %></td>
<td><%= rs.getString("valfim") %></td>
</tr>
</form>
<%
}//end of while
} catch (Exception ex) {
ex.printStackTrace( );
} finally {
if (rs != null) rs.close( );
if (st != null) st.close( );
if (conn !=null) conn.close( );
}
%>
</tbody>
</table>
</body>
</html>