1 Reply Latest reply on Dec 19, 2001 4:35 PM by bfalor

    Connecting MySql database using JDBC on Linux

    ashu



      Class.forName("org.gjt.mm.mysql.Driver");
      con=DriverManager.getConnection("jdbc:mysql://linuxserver:3306/dbname","root","");

      the above code works fine & get a connection with the mysql database specified as 'dbname'.

      but once i set a password to the database 'dbname' with user='root' & password='xyz' & change the above connect string as below....it does not work & throws an exception saying " user root@linuxserver cannot access ....etc"

      Class.forName("org.gjt.mm.mysql.Driver");
      con=DriverManager.getConnection("jdbc:mysql://linuxserver:3306/dbname","root","xyz");

      can u help me out with what connect string to use once u set a password for the database in mysql.
      Thanks for the help

        • 1. Re: Connecting MySql database using JDBC on Linux
          bfalor

          User root has two accounts in the mysql user table. Go in with the "mysql" command line query tool and you will see this. You must add the password to both. The mysql tools will use a local Unix socket, but jboss must use TCP/IP to connect. The second root@linuxserver record also has to have the password in its password column for your connection string to work. A quick and dirty way to update the one with the empty password, using the encrypted characters from the one with the password.