Hi everybody!
Ready to hear a strange story ?
I have a weird problem to use the MySQL-connector under Linux (Debian).
I have no problem in windows XP, all is working fine !
But under Linux when I try to connect to mysql throught mysql-connector wrote in a Servlet I have this message :
Message: Invalid authorization specification message from server: "Access denied for user 'root'@'monkinetwork' (using password: YES)"
SQLState: 28000
ErrorCode: 1045
Here the software I'm using :
Tomcat 5.0.28.
MySQL-Connector version is : mysql-connector-java-3.0.15-ga-bin.jar
JDK Version : 1_5_0_01. Servlet-Examples and JSP works fine! So I don't think the problem come from JDK.
MySQL version : MySQL-SERVER-4.1.9-2 : All is working under console mode !
Here's My Servlet TESt1.java:
Code:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.sql.DriverManager;
public class TEST1 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String url = "jdbc:mysql://localhost:3306/HeroDB";
String user = "root";
String password = "password";
try{
Class.forName("com.mysql.jdbc.Driver");
out.println("<br> DRIVERS JDBC : OK!");
Connection connection = DriverManager.getConnection(url,user,password);
out.println("<br> Database connection : OK!");
}
catch (ClassNotFoundException e)
{
out.println("Error with JDBC Drivers !");
}
catch(SQLException ex) {
out.println("<br> ERROR MESSAGE <br>");
while (ex != null) {
out.println("<br>Message: " + ex.getMessage ());
out.println("<br>SQLState: " + ex.getSQLState ());
out.println("<br>ErrorCode: " + ex.getErrorCode ());
ex = ex.getNextException();
out.println("");
}
}
}
}
AND THE HTML PAGE in order to access to the Servlet :
Code:
<HTML>
<HEAD>
<TITLE>DataBase Test</TITLE>
</HEAD>
<BODY BGCOLOR="#FDF5E6">
<H2 ALIGN="CENTER">DataBase TEST</H2>
<FORM ACTION="
http://localhost:8080/TEST1">
<CENTER>
<INPUT TYPE="SUBMIT" VALUE = "CONNEXION TEST">
</CENTER>
</FORM>
</BODY>
</HTML>
Theses codes works very well under windows, but under linux system here what I've got :
DRIVERS JDBC : OK!
ERROR MESSAGE
Message: Invalid authorization specification message from server: "Access denied for user 'root'@'monkinetwork' (using password: YES)"
SQLState: 28000
ErrorCode: 1045
Well, the web.xml file is well configured.
Anyway : I already tried with class: org.gjt.mm.mysql.driver, but I have the same message error !
By the way, it's very strange that I can play with MySQL under the terminal but not throught tomcat.
Any suggestions please , because it's giving me a very hard time ! ?
Thank you !
++
maxmaxx