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?