jdbc, MySQL, Access Denied



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.

.



Relevant Pages

  • Re: JDBC, applet, internet server
    ... I am trying to connect to MySQL database on an internet server using ... It looks like Connector/J is the JDBC driver provided by MySQL. ... I assume the database is under the control of a DBMS which is configured to allow database network connections from your location. ...
    (comp.lang.java.programmer)
  • Run JSP stored in a database
    ... Within the Tomcat environment I am trying to load JSP code that is ... I can retrieve the code via JDBC into a string, ... database structure that tracks many parameters associated with the form ...
    (comp.lang.java.programmer)
  • Re: Re: Need info, books, articles,code, etc: Access VBA to XML to/from MySQL via HTTP
    ... read, update, add and delete records located in tables in a MySQL database ... on a Web server on the Internet directly from my desktop Access application, ... the workstation needs a secure shell client running in order to enable the ... the MySQL database on your workstation ...
    (comp.databases.ms-access)
  • Re: Mixing P/R philosophy with OO (within J2EE).
    ... I have observed the work of literally hundreds of Java developers. ... Treating a database like a mere "persistence storage mechanisms" is on ... JDBC - Never before in history were so many database API's ... Topmind, if you're reading this, isn't this a good example of OOP? ...
    (comp.object)
  • Re: Re: Need info, books, articles,code, etc: Access VBA to XML to/from MySQL via HTTP
    ... Can the Access database application be co-located with the MySQL database on ... Which Web server is being used? ... a slightly complex problem pops up, the spoon-fed developer is going to be ...
    (comp.databases.ms-access)