Olá a todos!
Eu estou com um problema para fazer uma conexão com um banco de dados MYSQL, o erro que o eclipse mostra é referente a não encontrar o banco de dados que que passo na string de conexão. Se alguém puder me ajudar, segue os meus códigos:
[code]package Projeto;
import java.sql.*;
public class Conexao {
public void ConexaocomBD() throws SQLException{
//Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root","adminadmin");
Statement stmt = conn.createStatement();
stmt.executeUpdate(
"INSERT INTO USUARIOS " +
"VALUES ('José da Silva', jsilva@hxxx.com, 35)");
}
}[/code]
[code]<HTML><BODY>
<FORM METHOD=POST ACTION=“SaveName.jsp”>
What’s your name? <INPUT TYPE=TEXT NAME=username SIZE=20>
What’s your e-mail address? <INPUT TYPE=TEXT NAME=email SIZE=20>
What’s your age? <INPUT TYPE=TEXT NAME=age SIZE=4>
<INPUT TYPE=SUBMIT> </FORM> </BODY> </HTML>[/code]
[code]<jsp:useBean id=“user” class=“Projeto.UserData” scope=“session”/>
<jsp:setProperty name=“user” property="*"/>
<%@page import=“Projeto.UserData”%><HTML>
<BODY>
Continue
</BODY>
</HTML>[/code]
[code]<jsp:useBean id=“user” class=“Projeto.UserData” scope=“session”/>
<jsp:useBean id=“user2” class=“Projeto.Conexao”/>
<HTML>
<BODY>
<%
/* modificar o trecho abaixo para receber os dados, gravá-los , recuperá-los do banco
e exibi-los*/
user2.ConexaocomBD();
%>
You entered
Name: <%= user.getUsername() %>
Email: <%= user.getEmail() %>
Age: <%= user.getAge() %>
</BODY>
</HTML>[/code]
O Erro que aparece é o seguinte:
exception
[code]
org.apache.jasper.JasperException: No suitable driver found for jdbc:mysql://localhost:3306/mysql
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
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:729)
root cause
javax.servlet.ServletException: No suitable driver found for jdbc:mysql://localhost:3306/mysql
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.NextPage_jsp._jspService(NextPage_jsp.java:90)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
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:729)
root cause
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/mysql
java.sql.DriverManager.getConnection(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
Projeto.Conexao.ConexaocomBD(Conexao.java:8)
org.apache.jsp.NextPage_jsp._jspService(NextPage_jsp.java:68)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
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:729)[/code]