javaxamppnetbeans-8mysql-error-1064mysql-connector

I am not able to connect Netbeans to my Xampp(My Sql) Server. When I try to do so it shows "Communication failure error


I have Netbeans V8.2 with the latest version of Xampp installed on my mac. Successfully installed Xampp and created a database and also added My Sql connecter 8.0 to Netbeans but when I try to connect it to my database it shows " Communication failure error, the last packed send successfully to the server was 0 milliseconds ago. The driver has not received any packet from the server"

 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        String url="jdbc:mysql://localhost:8080/TEST";
       try
       {     
             Connection myconn= DriverManager.getConnection(url, "root", "");           
            String str="insert into AddStudent values(?,?,?,?)";
            PreparedStatement myst = myconn.prepareStatement(str);
            myst.setString(1,jTextField1.getText());
            myst.setString(2,jTextField2.getText());
            myst.setString(3,jTextField3.getText());
            myst.setString(4,jTextArea1.getText());
            int i=myst.executeUpdate();
            if(i==1)
            {
               JOptionPane.showMessageDialog(rootPane, "Student Added Successfully");

            }
       }    
            catch(SQLException e)
            {
                JOptionPane.showMessageDialog(rootPane, e.getMessage());
            }
            catch(Exception e)
            {
               JOptionPane.showMessageDialog(rootPane, e.getMessage());
            }
    } 

Solution

  • Normally mysql port in xampp is 3306 not 8080

    jdbc:mysql://localhost:3306/TEST