Re: Very Straneg problem with MySQL-Connector
Thank you very much for the explanation ! I am starting to understand it much better. Thank you everybody - Original Message - From: Parsons Technical Services [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Friday, February 25, 2005 1:20 AM Subject: Re: Very Straneg problem with MySQL-Connector For networking localhost=127.0.0.1=monkinetwork But when you attach to the database it sends the machine name in Linux and under MySQL localhost127.0.0.1monkinetwork and so you have to put in the location that is identified. When your app talks to MySQL, it tells MySQL it is calling from machine X, in your case the machine name is monkinetwork. Had you not named the machine it would have sent localhost if it was bound to the loopback address. And if that was not bound it would have sent the 127.0.0.1. You may also want to watch that if you bind Tomcat to an IP it may send that IP to MySQL if the machine name is not available. When you go across the network it will also use the IP of the machine. The easy way to tell is from the error. Access denied for user 'root'@'monkinetwork' (using password: YES) You were running Tomcat as root and the machine name is monkinetwork. Hope this helps. Doug - Original Message - From: monkiboy [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Thursday, February 24, 2005 5:04 PM Subject: Re: Very Straneg problem with MySQL-Connector Thank you for trying to help me everybody ! I read carefully your answer and it look like I have problem with privileges. My problem is resolved ! The first thing I did is : Comment this line on my.cnf file : # bind 127.0.0.1 Then the second thing that I made (with your advice) : is to try to connect on MySQL with User and not with the root. GRANT ALL PRIVILEGES ON testdb.* to 'test'@'localhost' IDENTIFIED BY 'test'; Doesn't work but when I did that : GRANT ALL PRIVILEGES ON testBDD.* to 'test'@'monkinetwork' IDENTIFIED BY 'test'; It's worked. It's look like I had to grant privilege on monkinetwork... It's very strange and I can't understand, I don't know why I had to do that... Best Regards. monkiboy OK, the problem normally does not come from the driver, just try this: from your freshly installed MySQL database, remove the test database and also the test user from the database permissions table and from any global user definitions, then flush-privileges and you should be ready to go. Drew. On Thu, 2005-02-24 at 03:01, monkiboy wrote: Hi everybody! I have a weird problem to use the MySQL-connector under Linux (Debian). I heard it can come from Tomcat. 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 I am 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(brMessage: + ex.getMessage ()); out.println(brSQLState: + ex.getSQLState ()); out.println(brErrorCode: + ex.getErrorCode ()); ex = ex.getNextException(); out.println(); } } } } AND THE HTML PAGE in order to access to the Servlet : Code: HTML HEAD TITLEDataBase Test/TITLE /HEAD BODY BGCOLOR=#FDF5E6 H2 ALIGN=CENTERDataBase TEST/H2 FORM ACTION=http://localhost:8080/TEST1; CENTER INPUT TYPE
Very Straneg problem with MySQL-Connector
Hi everybody! I have a weird problem to use the MySQL-connector under Linux (Debian). I heard it can come from Tomcat. 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 I am 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(brMessage: + ex.getMessage ()); out.println(brSQLState: + ex.getSQLState ()); out.println(brErrorCode: + ex.getErrorCode ()); ex = ex.getNextException(); out.println(); } } } } AND THE HTML PAGE in order to access to the Servlet : Code: HTML HEAD TITLEDataBase Test/TITLE /HEAD BODY BGCOLOR=#FDF5E6 H2 ALIGN=CENTERDataBase 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 ! ++ monkiboy
Re: Very Straneg problem with MySQL-Connector
Hi, your ploblem is most likely debian related. In debian mysql has a config parameter skip-networking which denies tcp connections to mysql. Make sure this setting is not set, and that you grant your user access from 127.0.0.1 not localhost because when using localhost mysql expects the user to connect via a unix socket, not a tcp socket. Good luck Trond monkiboy wrote: Hi everybody! I have a weird problem to use the MySQL-connector under Linux (Debian). I heard it can come from Tomcat. 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 I am 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(brMessage: + ex.getMessage ()); out.println(brSQLState: + ex.getSQLState ()); out.println(brErrorCode: + ex.getErrorCode ()); ex = ex.getNextException(); out.println(); } } } } AND THE HTML PAGE in order to access to the Servlet : Code: HTML HEAD TITLEDataBase Test/TITLE /HEAD BODY BGCOLOR=#FDF5E6 H2 ALIGN=CENTERDataBase 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 ! ++ monkiboy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Very Straneg problem with MySQL-Connector
Hello, Thank you for the answer but it's look like the parameter skip-networking is not present. I am really getting hard time. Here's my my.cnf : # # The MySQL database server configuration file. # # You can copy this to one of: # - /etc/mysql/my.cnf to set global options, # - /var/lib/mysql/my.cnf to set server-specific options or # - ~/.my.cnf to set user-specific options. # # One can use all long options that the program supports. # Run program with --help to get a list of available options and with # --print-defaults to see which it would actually understand and use. # # This will be passed to all mysql clients # It has been reported that passwords should be enclosed with ticks/quotes # escpecially if they contain # chars... [client] #password = my_password port = 3306 socket = /var/run/mysqld/mysqld.sock # Here is entries for some specific programs # The following values assume you have at least 32M ram # This was formally known as [safe_mysqld]. Both versions are currently parsed. [mysqld_safe] socket = /var/run/mysqld/mysqld.sock nice = 0 [mysqld] user = mysql pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock port = 3306 # Both location gets rotated by the cronjob. #log = /var/log/mysql.log log = /var/log/mysql/mysql.log basedir = /usr datadir = /var/lib/mysql tmpdir = /tmp language = /usr/share/mysql/english skip-external-locking # # For compatibility to other Debian packages that still use # libmysqlclient10 and libmysqlclient12. old-passwords = 1 # # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. bind-address = 127.0.0.1 key_buffer = 16M max_allowed_packet = 16M thread_stack = 128K # # Query Cache Configuration # query_cache_limit = 1048576 query_cache_size = 26214400 query_cache_type = 1 # # Here you can see queries with especially long duration #log-slow-queries = /var/log/mysql/mysql-slow.log # # The following can be used as easy to replay backup logs or for replication #server-id = 1 #log-bin = /var/log/mysql/mysql-bin.log #binlog-do-db = include_database_name #binlog-ignore-db = include_database_name # # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. # Read the manual for more InnoDB related options. There are many! # # Read the manual, too, if you want chroot! # chroot = /var/lib/mysql/ # # If you want to enable SSL support (recommended) read the manual or my # HOWTO in /usr/share/doc/mysql-server/SSL-MINI-HOWTO.txt # ssl-ca=/etc/mysql/cacert.pem # ssl-cert=/etc/mysql/server-cert.pem # ssl-key=/etc/mysql/server-key.pem [mysqldump] quick quote-names max_allowed_packet = 16M [mysql] #no-auto-rehash # faster start of mysql but no tab completition [isamchk] key_buffer = 16M Hi, your ploblem is most likely debian related. In debian mysql has a config parameter skip-networking which denies tcp connections to mysql. Make sure this setting is not set, and that you grant your user access from 127.0.0.1 not localhost because when using localhost mysql expects the user to connect via a unix socket, not a tcp socket. Good luck Trond monkiboy wrote: Hi everybody! I have a weird problem to use the MySQL-connector under Linux (Debian). I heard it can come from Tomcat. 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 I am 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(brMessage: + ex.getMessage ()); out.println(brSQLState: + ex.getSQLState ());
Re: Very Straneg problem with MySQL-Connector
Have you got the right permissions set up in the database? log into mysql. switch to the mysql database and look in the user table. You'll need to have an entry for host=monkinetwork, user=root. If you don't refer to the mysql admin docs for assigning privileges: http://dev.mysql.com/doc/mysql/en/user-account-management.html HTH, Jon monkiboy wrote: Hello, Thank you for the answer but it's look like the parameter skip-networking is not present. I am really getting hard time. Here's my my.cnf : AND THE HTML PAGE in order to access to the Servlet : 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 ! ++ monkiboy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Very Straneg problem with MySQL-Connector
Hi. The issue is mysql validates user, host, and password on login -- sort of a three factor authentication. Go into mysql and take a look at the result of these commands to see what users are defined: use mysql ; select user, host, password from user ; IMHO, don't use root from a webapp. Create a specific user for your webapp that only has the necessary rights. Here's an example, read the docs at http://www.mysql.com for more info: grant select, delete, insert, update on databaseNameHere.* to 'webappUsernameHere'@'monkinetwork' identified by 'passwordHere' ; Then update your web application's resource definition with the new username and password. --David monkiboy wrote: Hi everybody! I have a weird problem to use the MySQL-connector under Linux (Debian). I heard it can come from Tomcat. 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 I am 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(brMessage: + ex.getMessage ()); out.println(brSQLState: + ex.getSQLState ()); out.println(brErrorCode: + ex.getErrorCode ()); ex = ex.getNextException(); out.println(); } } } } AND THE HTML PAGE in order to access to the Servlet : Code: HTML HEAD TITLEDataBase Test/TITLE /HEAD BODY BGCOLOR=#FDF5E6 H2 ALIGN=CENTERDataBase 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 ! ++ monkiboy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Very Straneg problem with MySQL-Connector
monkiboy wrote: Hello, Thank you for the answer but it's look like the parameter skip-networking is not present. I am really getting hard time. Here's my my.cnf : Are Tomcat and MySQL running on the same machine? If not, you'll have to change the bind-address: # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. bind-address = 127.0.0.1 Regards mks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Very Straneg problem with MySQL-Connector
OK, the problem normally does not come from the driver, just try this: from your freshly installed MySQL database, remove the test database and also the test user from the database permissions table and from any global user definitions, then flush-privileges and you should be ready to go. Drew. On Thu, 2005-02-24 at 03:01, monkiboy wrote: Hi everybody! I have a weird problem to use the MySQL-connector under Linux (Debian). I heard it can come from Tomcat. 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 I am 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(brMessage: + ex.getMessage ()); out.println(brSQLState: + ex.getSQLState ()); out.println(brErrorCode: + ex.getErrorCode ()); ex = ex.getNextException(); out.println(); } } } } AND THE HTML PAGE in order to access to the Servlet : Code: HTML HEAD TITLEDataBase Test/TITLE /HEAD BODY BGCOLOR=#FDF5E6 H2 ALIGN=CENTERDataBase 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 ! ++ monkiboy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Very Straneg problem with MySQL-Connector
Thank you for trying to help me everybody ! I read carefully your answer and it look like I have problem with privileges. My problem is resolved ! The first thing I did is : Comment this line on my.cnf file : # bind 127.0.0.1 Then the second thing that I made (with your advice) : is to try to connect on MySQL with User and not with the root. GRANT ALL PRIVILEGES ON testdb.* to 'test'@'localhost' IDENTIFIED BY 'test'; Doesn't work but when I did that : GRANT ALL PRIVILEGES ON testBDD.* to 'test'@'monkinetwork' IDENTIFIED BY 'test'; It's worked. It's look like I had to grant privilege on monkinetwork... It's very strange and I can't understand, I don't know why I had to do that... Best Regards. monkiboy OK, the problem normally does not come from the driver, just try this: from your freshly installed MySQL database, remove the test database and also the test user from the database permissions table and from any global user definitions, then flush-privileges and you should be ready to go. Drew. On Thu, 2005-02-24 at 03:01, monkiboy wrote: Hi everybody! I have a weird problem to use the MySQL-connector under Linux (Debian). I heard it can come from Tomcat. 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 I am 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(brMessage: + ex.getMessage ()); out.println(brSQLState: + ex.getSQLState ()); out.println(brErrorCode: + ex.getErrorCode ()); ex = ex.getNextException(); out.println(); } } } } AND THE HTML PAGE in order to access to the Servlet : Code: HTML HEAD TITLEDataBase Test/TITLE /HEAD BODY BGCOLOR=#FDF5E6 H2 ALIGN=CENTERDataBase 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 ! ++ monkiboy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Very Straneg problem with MySQL-Connector
For networking localhost=127.0.0.1=monkinetwork But when you attach to the database it sends the machine name in Linux and under MySQL localhost127.0.0.1monkinetwork and so you have to put in the location that is identified. When your app talks to MySQL, it tells MySQL it is calling from machine X, in your case the machine name is monkinetwork. Had you not named the machine it would have sent localhost if it was bound to the loopback address. And if that was not bound it would have sent the 127.0.0.1. You may also want to watch that if you bind Tomcat to an IP it may send that IP to MySQL if the machine name is not available. When you go across the network it will also use the IP of the machine. The easy way to tell is from the error. Access denied for user 'root'@'monkinetwork' (using password: YES) You were running Tomcat as root and the machine name is monkinetwork. Hope this helps. Doug - Original Message - From: monkiboy [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Thursday, February 24, 2005 5:04 PM Subject: Re: Very Straneg problem with MySQL-Connector Thank you for trying to help me everybody ! I read carefully your answer and it look like I have problem with privileges. My problem is resolved ! The first thing I did is : Comment this line on my.cnf file : # bind 127.0.0.1 Then the second thing that I made (with your advice) : is to try to connect on MySQL with User and not with the root. GRANT ALL PRIVILEGES ON testdb.* to 'test'@'localhost' IDENTIFIED BY 'test'; Doesn't work but when I did that : GRANT ALL PRIVILEGES ON testBDD.* to 'test'@'monkinetwork' IDENTIFIED BY 'test'; It's worked. It's look like I had to grant privilege on monkinetwork... It's very strange and I can't understand, I don't know why I had to do that... Best Regards. monkiboy OK, the problem normally does not come from the driver, just try this: from your freshly installed MySQL database, remove the test database and also the test user from the database permissions table and from any global user definitions, then flush-privileges and you should be ready to go. Drew. On Thu, 2005-02-24 at 03:01, monkiboy wrote: Hi everybody! I have a weird problem to use the MySQL-connector under Linux (Debian). I heard it can come from Tomcat. 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 I am 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(brMessage: + ex.getMessage ()); out.println(brSQLState: + ex.getSQLState ()); out.println(brErrorCode: + ex.getErrorCode ()); ex = ex.getNextException(); out.println(); } } } } AND THE HTML PAGE in order to access to the Servlet : Code: HTML HEAD TITLEDataBase Test/TITLE /HEAD BODY BGCOLOR=#FDF5E6 H2 ALIGN=CENTERDataBase 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