jdbc, MySQL, Access Denied
- From: boanator@xxxxxxxxxxxxx
- Date: 21 Jun 2005 07:12:50 -0700
I am writing a website of JSP pages to access a MySQL database. I am
trying to use jdbc to connect to the database. Whenever I try to
access the database, I get the following exception:
javax.servlet.ServletException: Access denied for user ''@'localhost'
(using password: NO)
This is the JSP page that is trying to access it:
// Contents of AccessMySQL.jsp
<%@ page import="java.sql.*" %>
<%
String connectionURL =
"jdbc:mysql://localhost:3306/myDatabase?user=root&password=myPassword";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
%>
<html><body>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "", "");
statement = connection.createStatement();
rs = statement.executeQuery("SELECT * FROM table01");
while (rs.next()) {
out.println(rs.getString("myfield")+"<br>");
}
rs.close();
%>
</body></html>
Does anyone know what I am doing wrong? Do I have to set something in
jdbc? Do I have to set a new user and password for localhost for
MySQL?
Any advice would be appreciated. Thanks in advance.
.
- Follow-Ups:
- Re: jdbc, MySQL, Access Denied
- From: boanator
- Re: jdbc, MySQL, Access Denied
- Prev by Date: Re: Databases and IPv6
- Next by Date: Re: Databases and IPv6
- Previous by thread: Why did COMMIT solved my Java->PL/SQL problem?
- Next by thread: Re: jdbc, MySQL, Access Denied
- Index(es):
Relevant Pages
|
|