[Resolvido] Montando uma tabela de um resultset

tou querdno montar uma tabela (html) de um resultset do meu banco
Só que está dando um erro e eu não tou conseguindo achar…
alguem pode me ajudar?

<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/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>Untitled Document</title>
</head>
<body>
<%			
	Class.forName("org.postgresql.Driver");
	String url = "jdbc:postgresql://localhost/dwbd";
	Connection c = DriverManager.getConnection(url,"postgres","321321");
	
	Statement st = conn.createStatement();
	ResultSet rs = st.executeQuery("Select * from ger_pessoa");
	st.close(); 
%>
<table width="50%" align="center" border="1" >
	<tr>
    	<td>Código </td>
        <td>Nome </td>
    </tr>
<% while rs.next() {
%>
	<tr>
    	<td> <%= rs.getInt("pes_cod") %> </td>
        <td> <%= rs.getString("pes_nome") %> </td>
    </tr>
<%
}
%>
</table>    
</body>

</html>

o erro é esse:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP: 
JSP FileName:/index.jsp
Java FileName:/C:/Arquivos de programas/Apache Software Foundation/Tomcat 5.5/webapps/dwbd/work//org/apache/jsp\index_jsp.java

An error occurred at line: 14 in the jsp file: /index.jsp
conn cannot be resolved
11: 	String url = "jdbc:postgresql://localhost/dwbd";
12: 	Connection c = DriverManager.getConnection(url,"postgres","321321");
13: 	
14: 	Statement st = conn.createStatement();
15: 	ResultSet rs = st.executeQuery("Select * from ger_pessoa");
16: 	st.close(); 
17: %>


Stacktrace:
	org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:98)
	org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
	org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.25 logs.
Apache Tomcat/5.5.25

Pelo que eu entendi, o erro está no resultset…
alguem pode me ajudar?

O problema é que na linha 12 vc declarou a variavel “c” como uma Connection, mas na linha 14 ao invés de utilizar a variável “c” vc está utilizando a variável “conn” que não foi declarada.

É… esse erro eu já tinha resolvido… tinha me passado memso, tinha esquecido de vim aquir e postar…
agora tou com outro erro

[code]<%@ page contentType=“text/html; charset=utf-8” language=“java” import=“java.sql.*” errorPage="" %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/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>Untitled Document</title>
</head>
<body>
<%
try{
Class.forName(“org.postgresql.Driver”);
String url = “jdbc:postgresql://localhost/dwbd”;
Connection c = DriverManager.getConnection(url,“postgres”,“321321”);

	Statement st = c.createStatement();
	ResultSet rs = st.executeQuery("Select * from ger_pessoa");
	st.close(); 
}catch (Exception e) {}

%>

<table width=“50%” align=“center” border=“1” >
<tr>
<td>Código </td>
<td>Nome </td>
</tr>
<% while ( rs.next() ) {
%>

&lt;tr&gt;
	&lt;td&gt; &lt;%= rs.getInt("pes_cod") %&gt; &lt;/td&gt;
    &lt;td&gt; &lt;%= rs.getString("pes_nome") %&gt; &lt;/td&gt;
&lt;/tr&gt;

<%
}
%>
</table>

</body>

</html>
[/code]

o erro:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP: 
JSP FileName:/index.jsp
Java FileName:/C:/Arquivos de programas/Apache Software Foundation/Tomcat 5.5/webapps/dwbd/work//org/apache/jsp\index_jsp.java

An error occurred at line: 28 in the jsp file: /index.jsp
rs cannot be resolved
25:     &lt;/tr&gt;
26: 
27: 	&lt;tr&gt;
28:     	&lt;td&gt; &lt;%= rs.getInt(1) %&gt; &lt;/td&gt;
29:         &lt;td&gt; &lt;%= rs.getString(2) %&gt; &lt;/td&gt;
30:     &lt;/tr&gt;
31: 

JSP FileName:/index.jsp
Java FileName:/C:/Arquivos de programas/Apache Software Foundation/Tomcat 5.5/webapps/dwbd/work//org/apache/jsp\index_jsp.java

An error occurred at line: 29 in the jsp file: /index.jsp
rs cannot be resolved
26: 
27: 	&lt;tr&gt;
28:     	&lt;td&gt; &lt;%= rs.getInt(1) %&gt; &lt;/td&gt;
29:         &lt;td&gt; &lt;%= rs.getString(2) %&gt; &lt;/td&gt;
30:     &lt;/tr&gt;
31: 
32: &lt;/table&gt;   


Stacktrace:
	org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:98)
	org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
	org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.25 logs.
Apache Tomcat/5.5.25

esse erro é no resultset, onde eu uso o rs dá o erro

alguem me ajuda de novo?

*** CORRIGIDO ***
eu fechava o Statment no inico, ai num rodava… isso que dar ficar copiando e colando

segue o código corrido

&lt;%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %&gt;
&lt;head&gt;
&lt;title&gt;Teste&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;%	
	Class.forName("org.postgresql.Driver");
	String url = "jdbc:postgresql://localhost/dwbd";
	Connection c = DriverManager.getConnection(url,"postgres","321321");

	Statement st = c.createStatement();
	ResultSet result = st.executeQuery("Select pes_cod, pes_nome from ger_pessoa");
	String pes_nome = "";
	int pes_cod;

%&gt;
&lt;table width="50%" align="center" border="1" &gt;
	&lt;tr&gt;
    	&lt;td&gt;Código &lt;/td&gt;
        &lt;td&gt;Nome &lt;/td&gt;
    &lt;/tr&gt;
&lt;% while ( result.next() ) {
%&gt;

	&lt;tr&gt;
    	&lt;td&gt; &lt;%= result.getInt("pes_cod") %&gt; &lt;/td&gt;
        &lt;td&gt; &lt;%= result.getString("pes_nome") %&gt; &lt;/td&gt;
    &lt;/tr&gt;
&lt;%
}
%&gt;
&lt;/table&gt;  

&lt;/body&gt;

&lt;/html&gt;

Podia da erro no try antes do rs ser declarado e tem q cuidar para não deixar nada preso no BD!
Testa essa versão ai:

<%@ page contentType=“text/html; charset=utf-8” language=“java” import=“java.sql.*” errorPage="" %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/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>Untitled Document</title>
</head>
<body>
[color=red]<table width=“50%” align=“center” border=“1” >
<tr>
<td>Código </td>
<td>Nome </td>
</tr>
</table>
<%
Connection c = null;
Statement st = null;
ResultSet rs = null;
try{
Class.forName(“org.postgresql.Driver”);
String url = “jdbc:postgresql://localhost/dwbd”;
c = DriverManager.getConnection(url,“postgres”,“321321”);

    st = c.createStatement();   
    rs = st.executeQuery("Select * from ger_pessoa");   

while ( rs.next() ) {
%>

&lt;tr&gt;   
    &lt;td&gt; &lt;%= rs.getInt("pes_cod") %&gt; &lt;/td&gt;   
    &lt;td&gt; &lt;%= rs.getString("pes_nome") %&gt; &lt;/td&gt;   
&lt;/tr&gt;   

<%
}

}catch (Exception e) {
} finally {

if(c != null)
c.close();
if(st != null)
st.close();
if(rs != null)
rs.close();
}
%> [/color]

</body>

</html>