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...<%--
Document : consulta
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>formulario de consulta</title>
</head>
<body>
<form action="folha2.jsp" method="post" name="dados" onSubmit="return enviardados();" >
<table width="588" border="0" align="center" >
<tr>
<td width="118" bgcolor="#CCCCCC"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>CODIGO:</strong></font></td>
<td width="460" bgcolor="#CCCCCC">
<input name="codigo" type="text" class="formbutton" id="codigo" size="52" maxlength="150"/>
</td>
</tr>
<tr>
<td width="118" bgcolor="#CCCCCC"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>MÊS:</strong></font></td>
<td width="460" bgcolor="#CCCCCC">
<input name="mes" type="text" class="formbutton" id="mes" size="52" maxlength="150"/>
</td>
</tr>
<tr>
<td width="118" bgcolor="#CCCCCC"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>ANO:</strong></font></td>
<td width="460" bgcolor="#CCCCCC">
<input name="ano" type="text" class="formbutton" id="ano" size="52" maxlength="150"/>
</td>
</tr>
<tr>
<td height="22" bgcolor="#CCCCCC"> </td>
<td bgcolor="#CCCCCC">
<input type="submit" class="formobjects" value="Enviar dados" />
<input name="Reset" type="reset" class="formobjects" value="Redefinir" />
</td>
</tr>
</table>
</form>
</body>
</html>
Aqui 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>
