Problemas com myql

3 respostas
D

Bom dia…

É o seguinte, eu tenho o seguinte fabrica de conexão com o banco:

public class FabricaDeConexao {

private Connection con;
	
	public Connection getConnectionFactory(){
		
		try {
			try {
				Class.forName("com.mysql.Driver");
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			return con = DriverManager.getConnection("jdbc:mysql://localhost/incriveis", "", "1234");
		} catch (SQLException e) {
			
			throw new RuntimeException(e);
		}
		
	}

}

Mas esta gerando o Erro abixo:
description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.RuntimeException: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/incriveis

br.com.incriveisvip.conexao.FabricaDeConexao.getConnectionFactory(FabricaDeConexao.java:23)

br.com.incriveisvip.DAO.IntegranteDAO.(IntegranteDAO.java:19)

br.com.incriveisvip.servlets.IncriveisServlet.doPost(IncriveisServlet.java:41)

javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/incriveis

java.sql.DriverManager.getConnection(Unknown Source)

java.sql.DriverManager.getConnection(Unknown Source)

br.com.incriveisvip.conexao.FabricaDeConexao.getConnectionFactory(FabricaDeConexao.java:20)

br.com.incriveisvip.DAO.IntegranteDAO.(IntegranteDAO.java:19)

br.com.incriveisvip.servlets.IncriveisServlet.doPost(IncriveisServlet.java:41)

javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

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

Podem me ajudar a resolve-lo?

desde de já fico grato!!
Abraços

3 Respostas

jamirdeajr

Você adicionou o .jar do driver MySQL na tua aplicação?
Se sim, verifique se não pegou uma versão antiga.

Tem muitos posts aqui sobre este erro, dá uma pesquisada, ex:
http://www.guj.com.br/java/199454-erro–aplicacao-web-sou-iniciante-
http://www.guj.com.br/prepost/204831/1040513/desesperono-suitable-driver-found-for-jdbcmysqllocalhost3306
etc…
Se puder quando postar trechos de código/exceções inclua as tags ‘code’, fica bem mais fácil de visualizar, blz

julianosts

Olha o erro no codigo que postou:
java.lang.RuntimeException: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/incriveis

Como o amigo disse acima, pode estar faltando o jar do mysql

LPJava

dar uma olhada neste post, ver se ti ajuda: http://camilolopes.wordpress.com/2009/04/14/criando-conexao-java-mysql-com-eclipse/

acho que vai ti ajudar.

Criado 22 de abril de 2011
Ultima resposta 23 de abr. de 2011
Respostas 3
Participantes 4