Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.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
MySQL连接:主机';x、 y.z.z';不允许_Mysql_Connection - Fatal编程技术网

MySQL连接:主机';x、 y.z.z';不允许

MySQL连接:主机';x、 y.z.z';不允许,mysql,connection,Mysql,Connection,我正在尝试从客户机(192.168.1.102)连接运行XAMPP 1.8.3(MySQL 5.6.16 GPL)的MySQL服务器(192.168.1.108),但我收到以下错误: SQL异常:null,来自服务器的消息:Host'192.168.1.108'为空 不允许连接到此MySQL服务器 这是连接代码: public Connection connect(String host) { try { String driver=t

我正在尝试从客户机(
192.168.1.102
)连接运行
XAMPP 1.8.3(MySQL 5.6.16 GPL)
的MySQL服务器(
192.168.1.108
),但我收到以下错误:

SQL异常:null
,来自服务器的消息:
Host'192.168.1.108'
为空 不允许连接到此MySQL服务器

这是连接代码:

public Connection connect(String host) {
    try {                   
       String driver=textDriver.getText();
       // String host=textServer.getText();
       String db=textDatabase.getText();
       String user=textUser.getText();
       String pwd=txtPass.getText();       

       URL = "jdbc:mysql://"+ host +"/"+ db +"?user=" + user +"&password="+ pwd;

       Class.forName(driver);
       cn = DriverManager.getConnection(URL);
       connected=true;      

       JOptionPane.showMessageDialog(this, "Connection : " + cn.getCatalog(),
                                     "Database Connection",  
                                     JOptionPane.INFORMATION_MESSAGE);
       return cn;
    }
    catch (SQLException e){
       JOptionPane.showMessageDialog(this, "Not Connected : " + e);   
       return null;
    }
} 
这是主代码(调用者):


有人能帮我一下吗…

您是否已从服务器授予计算机的用户权限?因为这是一个SQL错误,所以这不是纯粹的网络问题。这看起来更像是mysql内部的权限问题,尽管我对确切的错误消息听起来并不熟悉。我会说,检查内部“mysql”数据库中授予的访问权限。
public static void main(String[] args) {
    // 127.0.0.1
    String host = "localhost"; 
    try {
        String client = JOptionPane.showInputDialog(null, "Is this client(y/n)", "y");
        if (client .equals("y") || client.equals("Y")) {
            // Client must connect to the server(192.168.1.102)                
            host = "192.168.1.102";    
        }            

        Conn = dialog.connect(host);
        if (dialog.connected == true)   {                        
            dialog.setVisible(false);
            dialog.dispose();    
        }
    } catch (Exception e) {
        e.printStackTrace();
    }                                

    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            createAndShowGUI();
        }
    });
}