Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用Netbeans连接到远程mySQL(cPanel、phpMyAdmin)_Java_Mysql_Netbeans - Fatal编程技术网

Java 使用Netbeans连接到远程mySQL(cPanel、phpMyAdmin)

Java 使用Netbeans连接到远程mySQL(cPanel、phpMyAdmin),java,mysql,netbeans,Java,Mysql,Netbeans,我已经在远程主机上使用cPanel和phpMyAdmin为我的网站创建了MySQL数据库,现在我想通过我的简单java程序连接到该数据库。我尝试以下代码: import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; public class Main { public static void main(String[] args) { try{ Con

我已经在远程主机上使用cPanel和phpMyAdmin为我的网站创建了MySQL数据库,现在我想通过我的简单java程序连接到该数据库。我尝试以下代码:

 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.Statement;

   public class Main {

public static void main(String[] args) {
   try{
      Connection con=DriverManager.getConnection("jdbc:mysql://sfg.ge/sfgge_mysql",     "my_username", "my_password");

      Statement state=(Statement) con.createStatement();
      String name="shota";
      int id=3;
      String insert = "INSERT INTO student VALUES ("+ id +",'"+ name +"')";
      state.executeUpdate(insert);
      }
   catch(Exception ex){

   }
 }
}
在此代码中

       DriverManager.getConnection(String url, username, pass) 
SQLException引发以下错误:

    null,  message from server: 
    "Host '188.129.228.176' is not allowed to connect to this     MySQL server"
感谢您的建议。

添加新帐户:

'user1'@'exact_host' - host is specified

CREATE USER 'user1'@'exact_host'

授予您所需的权限并连接到新帐户。 再看看这个:

Make sure that the server has not been configured to ignore network connections or (if you are attempting to connect remotely) that it has not been configured to listen only locally on its network interfaces. If the server was started with --skip-networking, it will not accept TCP/IP connections at all. If the server was started with --bind-address=127.0.0.1, it will listen for TCP/IP connections only locally on the loopback interface and will not accept remote connections
Make sure that the server has not been configured to ignore network connections or (if you are attempting to connect remotely) that it has not been configured to listen only locally on its network interfaces. If the server was started with --skip-networking, it will not accept TCP/IP connections at all. If the server was started with --bind-address=127.0.0.1, it will listen for TCP/IP connections only locally on the loopback interface and will not accept remote connections