Estou tentando criar um código JSP que conecte com o MySQL e retorne os dados de uma tabela.
Para isso estou utilizando o NetBeans 5.0, fui em Library Manager e adicionei o JAR do Driver JDBC do MySQL (Não sei se este é o passo correto para adicionar um JAR de um Driver JDBC).
Estou utilizando o seguinte código:
<%Class.forName("com.mysql.jdbc.Driver");Connectionconn=DriverManager.getConnection("jdbc:mysql://localhost/db_noticia?user=root&password=TabX5Mfc8");Statementstm=conn.createStatement("SELECT DS_TITULO,DT_NOTICIA FROM CAD_NOTICIA");ResultSetrs=stm.execute();System.out.println("<table width='100%'>");System.out.println("<tr>");System.out.println("<td width='80%'>Título</td>");System.out.println("<td>Data</td>");System.out.println("</tr>");while(rs.next()){System.out.println("<tr>");StringstrTitulo=rs.getString("DS_TITULO");DatedtNoticia=rs.getDate("DT_NOTICIA");System.out.println("<td>"+strTitulo+"</td>");System.out.println("<td>"+dtNoticia.toString()+"</td>");System.out.println("</tr>");}System.out.println("</table>");%>
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
An error occurred at line: 24 in the jsp file: /index.jsp
Generated servlet error:
C:\Documents and Settings\Juliano.netbeans\5.0\jakarta-tomcat-5.5.9_base\work\Catalina\localhost\DB1\org\apache\jsp\index_jsp.java:62: cannot find symbol
symbol : class Connection
location: class org.apache.jsp.index_jsp
An error occurred at line: 24 in the jsp file: /index.jsp
Generated servlet error:
Connection conn = DriverManager.getConnection(“jdbc:mysql://localhost/db_noticia?user=root&password=TabX5Mfc8”);
^
An error occurred at line: 24 in the jsp file: /index.jsp
Generated servlet error:
C:\Documents and Settings\Juliano.netbeans\5.0\jakarta-tomcat-5.5.9_base\work\Catalina\localhost\DB1\org\apache\jsp\index_jsp.java:62: cannot find symbol
symbol : variable DriverManager
location: class org.apache.jsp.index_jsp
An error occurred at line: 24 in the jsp file: /index.jsp
Generated servlet error:
Connection conn = DriverManager.getConnection(“jdbc:mysql://localhost/db_noticia?user=root&password=TabX5Mfc8”);
^
An error occurred at line: 24 in the jsp file: /index.jsp
Generated servlet error:
C:\Documents and Settings\Juliano.netbeans\5.0\jakarta-tomcat-5.5.9_base\work\Catalina\localhost\DB1\org\apache\jsp\index_jsp.java:64: cannot find symbol
symbol : class Statement
location: class org.apache.jsp.index_jsp
Statement stm = conn.createStatement(“SELECT DS_TITULO,DT_NOTICIA FROM CAD_NOTICIA”);
^
An error occurred at line: 24 in the jsp file: /index.jsp
Generated servlet error:
C:\Documents and Settings\Juliano.netbeans\5.0\jakarta-tomcat-5.5.9_base\work\Catalina\localhost\DB1\org\apache\jsp\index_jsp.java:65: cannot find symbol
symbol : class ResultSet
location: class org.apache.jsp.index_jsp
ResultSet rs = stm.execute();
^
An error occurred at line: 24 in the jsp file: /index.jsp
Generated servlet error:
C:\Documents and Settings\Juliano.netbeans\5.0\jakarta-tomcat-5.5.9_base\work\Catalina\localhost\DB1\org\apache\jsp\index_jsp.java:78: cannot find symbol
symbol : class Date
location: class org.apache.jsp.index_jsp
Date dtNoticia = rs.getDate(“DT_NOTICIA”);
^
5 errors