Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2002
    Posts
    16

    Unanswered: java connect error

    I'm having some problems with a java app I'm writing for school. I have mysql running on my local box and the database and table exist. The user has insert update select delete rights. I have the mysql connectj driver installed.

    MY CODE:
    try
    {
    //using MySQL database connectj driver
    //www.mysql.com
    //syntax example:
    //String cs = "jdbc:mysql://"+dbserver+"/"+dbname+"?user="+user
    +"&password="+password;
    url = "jdbc:mysql://127.0.0.1:3306/TS5502?user=java&password=secret";
    //register the MySQL Driver
    Class.forName("com.mysql.jdbc.Driver").newInstance ();
    connect = DriverManager.getConnection(url);
    connectField.setText("Connection successful");

    }
    catch(ClassNotFoundException cnfx)
    {
    cnfx.printStackTrace();
    connectField.setText("Connection unsuccessful" + cnfx.toString());
    }
    catch (SQLException sqlx)
    {
    sqlx.printStackTrace();
    connectField.setText("Connection unsuccessful" + sqlx.toString());
    }
    catch (Exception ex)
    {
    ex.printStackTrace();
    connectField.setText("Connection unsuccessful" + ex.toString());
    }


    THE ERROR:

    java.sql.SQLException: Unable to connect to any hosts due to exception:
    java.security.AccessControlException: access denied
    (java.net.SocketPermission 127.0.0.1:3306 connect,resolve)
    at com.mysql.jdbc.Connection.createNewIO(Connection.j ava:1797)
    at com.mysql.jdbc.Connection.<init>(Connection.java:5 62)
    at
    com.mysql.jdbc.NonRegisteringDriver.connect(NonReg isteringDriver.java:361)
    at java.sql.DriverManager.getConnection(DriverManager .java:512)
    at java.sql.DriverManager.getConnection(DriverManager .java:193)
    at finalProject.AddressBook.myInit(AddressBook.java:3 98)
    at finalProject.AddressBook.init(AddressBook.java:85)
    at sun.applet.AppletPanel.run(AppletPanel.java:353)
    at java.lang.Thread.run(Thread.java:534)

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: java connect error

    This is a MYSQL Question ...

    Please post only in the appropriate forum(s) ...

    Cheers
    Sathyaram

    Originally posted by CaptainEstock
    I'm having some problems with a java app I'm writing for school. I have mysql running on my local box and the database and table exist. The user has insert update select delete rights. I have the mysql connectj driver installed.

    MY CODE:
    try
    {
    //using MySQL database connectj driver
    //www.mysql.com
    //syntax example:
    //String cs = "jdbc:mysql://"+dbserver+"/"+dbname+"?user="+user
    +"&password="+password;
    url = "jdbc:mysql://127.0.0.1:3306/TS5502?user=java&password=secret";
    //register the MySQL Driver
    Class.forName("com.mysql.jdbc.Driver").newInstance ();
    connect = DriverManager.getConnection(url);
    connectField.setText("Connection successful");

    }
    catch(ClassNotFoundException cnfx)
    {
    cnfx.printStackTrace();
    connectField.setText("Connection unsuccessful" + cnfx.toString());
    }
    catch (SQLException sqlx)
    {
    sqlx.printStackTrace();
    connectField.setText("Connection unsuccessful" + sqlx.toString());
    }
    catch (Exception ex)
    {
    ex.printStackTrace();
    connectField.setText("Connection unsuccessful" + ex.toString());
    }


    THE ERROR:

    java.sql.SQLException: Unable to connect to any hosts due to exception:
    java.security.AccessControlException: access denied
    (java.net.SocketPermission 127.0.0.1:3306 connect,resolve)
    at com.mysql.jdbc.Connection.createNewIO(Connection.j ava:1797)
    at com.mysql.jdbc.Connection.<init>(Connection.java:5 62)
    at
    com.mysql.jdbc.NonRegisteringDriver.connect(NonReg isteringDriver.java:361)
    at java.sql.DriverManager.getConnection(DriverManager .java:512)
    at java.sql.DriverManager.getConnection(DriverManager .java:193)
    at finalProject.AddressBook.myInit(AddressBook.java:3 98)
    at finalProject.AddressBook.init(AddressBook.java:85)
    at sun.applet.AppletPanel.run(AppletPanel.java:353)
    at java.lang.Thread.run(Thread.java:534)
    Visit the new-look IDUG Website , register to gain access to the excellent content.

Posting Permissions

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