Pessoal, estou com um problema neste projeto pois, se entendi bem a exception, ha algum problema na assinatura do drive. alguem sabe o q pode ser?
//classe de conexoes
package br.com.testesweb;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Conexao {
public static Connection getConnection() throws SQLException {
try {
Class.forName("com.mysql.jdbc.Driver");
return DriverManager.getConnection("jdbc:mysql://localhost/sistemas",
"root","root");
} catch (ClassNotFoundException e) {
throw new SQLException(e.getMessage());
}
}
}
//classe dao
package br.com.testesweb;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class DAO {
public DAO() throws SQLException {
imprime();
}
public void imprime()throws SQLException{
Connection con = Conexao.getConnection();
PreparedStatement stmt = con.prepareStatement("select * from contatos");
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
System.out.println(
rs.getString("nome") + " :: " + rs.getString("email")
);
}
stmt.close();
con.close();
}
}
classe main teste:
package br.com.testesweb;
import java.sql.SQLException;
public class teste {
static public void main(String[] args) throws SQLException{
new DAO();
}
}
<%-- conecta.jsp:–%>
<%@ page import="java.sql.*, br.com.testesweb.*"%>
<%
String s = "moises";
out.println(s);
new DAO();
%>
exception gerada:
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: com.mysql.jdbc.Driver
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
javax.servlet.ServletException: com.mysql.jdbc.Driver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:843)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:776)
org.apache.jsp.conecta_jsp._jspService(conecta_jsp.java:56)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.sql.SQLException: com.mysql.jdbc.Driver
br.com.moises.testes.Conexao.getConnection(Conexao.java:15)
br.com.moises.testes.DAO.imprime(DAO.java:16)
br.com.moises.testes.DAO.<init>(DAO.java:12)
org.apache.jsp.conecta_jsp._jspService(conecta_jsp.java:49)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.5.20
Bom, por isso acho q é algo na assinatura do drive.
obrigado por enquanto.
[color=red]Mensagem do moderador: Ao postar codigos utilize a tag [ code ]. [/color]