Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003
    Location
    Stockholm
    Posts
    3

    Unanswered: Data source rejected establishment of connection

    Hello,

    All of a sudden mysql refuse my javaprogram to connect. It's a local connection on my tao-lunix-machine.
    I have tried;
    mysqladmin flush-hosts
    and...
    GRANT USAGE ON *.* TO 'myUser'@'localhost' IDENTIFIED BY 'mypassword';
    GRANT ALL PRIVILEGES ON groopidb.* TO 'myuser'@'localhost' WITH GRANT OPTION;

    Any one who knows the cure?

    You can se my simple test program below and it's output.

    Thanks in advance,

    Jan Gifvars,

    --------------- error output from my javaprogram -----------
    Starting ...
    Object org.gjt.mm.mysql.Driver@126b249
    Caught SQLException when invoking DriverManager.getConnection()
    SQLException: Data source rejected establishment of connection, message from server: "Host 'localhost.localdomain' is
    not allowed to connect to this MySQL server"
    SQLState: 08004
    VendorError: 1130
    java.sql.SQLException: Data source rejected establishment of connection, message from server: "Host 'localhost.locald
    omain' is not allowed to connect to this MySQL server"
    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:58 2)
    at com.mysql.jdbc.Connection.createNewIO(Connection.j ava:1627)
    at com.mysql.jdbc.Connection.<init>(Connection.java:4 27)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonReg isteringDriver.java:395)
    at java.sql.DriverManager.getConnection(DriverManager .java:512)
    at java.sql.DriverManager.getConnection(DriverManager .java:193)
    at groopi.test.SimpleDBTest.main(SimpleDBTest.java:42 )
    Connection con:null
    2Caught SQLException when invoking DriverManager.getConnection()
    2SQLException: Data source rejected establishment of connection, message from server: "Host 'localhost.localdomain' i
    s not allowed to connect to this MySQL server"
    2SQLState: 08004
    2VendorError: 1130
    java.sql.SQLException: Data source rejected establishment of connection, message from server: "Host 'localhost.locald
    omain' is not allowed to connect to this MySQL server"
    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:58 2)
    at com.mysql.jdbc.Connection.createNewIO(Connection.j ava:1627)
    at com.mysql.jdbc.Connection.<init>(Connection.java:4 27)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonReg isteringDriver.java:395)
    at java.sql.DriverManager.getConnection(DriverManager .java:512)
    at java.sql.DriverManager.getConnection(DriverManager .java:140)
    at groopi.test.SimpleDBTest.main(SimpleDBTest.java:61 )
    2Connection con:null


    -------------------- Java program --------------------------------

    public class SimpleDBTest {

    public static void main (String[] args)
    {
    String database = "jdbc:mysql://localhost/groopidb";
    String tUser = "?user=root&password=mypassword";

    System.out.println("Starting ... ");

    Object o = null;
    Connection con = null;
    try
    {
    o = Class.forName("org.gjt.mm.mysql.Driver").newInstan ce();
    //o = Class.forName("com.mysql.Driver").newInstance();
    }
    catch (Exception e)
    {
    System.err.println("Unable to load driver.");
    e.printStackTrace();
    }

    System.out.println("Object o:" + o);
    try
    {
    con = DriverManager.getConnection(database + tUser);
    }
    catch (SQLException sqle)
    {
    System.out.println("Caught SQLException when invoking DriverManager.getConnection()");
    System.out.println("SQLException: " + sqle.getMessage());
    System.out.println("SQLState: " + sqle.getSQLState());
    System.out.println("VendorError: " + sqle.getErrorCode());
    sqle.printStackTrace();
    }
    System.out.println("Connection con:" + con);
    try
    {
    Properties tProps;
    tProps = new Properties();

    tProps.put("user", "root");
    tProps.put("password","p93fzKkr");

    con = DriverManager.getConnection(database, tProps);

    //con = DriverManager.getConnection(database );
    }
    catch (SQLException sqle)
    {
    System.out.println("2Caught SQLException when invoking DriverManager.getConnection()");
    System.out.println("2SQLException: " + sqle.getMessage());
    System.out.println("2SQLState: " + sqle.getSQLState());
    System.out.println("2VendorError: " + sqle.getErrorCode());
    sqle.printStackTrace();
    }
    System.out.println("2Connection con:" + con);

    }

    }

  2. #2
    Join Date
    Sep 2004
    Posts
    1

    Did you ever receive a solution to this?

    I have the same problem. Did you ever get an answer to this?

  3. #3
    Join Date
    Mar 2003
    Location
    Stockholm
    Posts
    3
    Hello Jeichels,

    Yes change localhost in the url to the name on your computer. Perhaps it also works with the IP-address.

    Good luck,

    -JG

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •