Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why netbenas cannot connect to mysql?

I have a mysql database called employee.
I want to connect to this database using netbeans.

I get the following exception:

ava.sql.SQLNonTransientConnectionException: Cannot load connection class because of underlying exception: com.mysql.cj.exceptions.WrongArgumentException: Failed to parse the host:port pair ‘localhost:3306:employee’.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

My code is:

try {
           Class.forName("com.mysql.jdbc.Driver");
       } catch (ClassNotFoundException ex) {
          ex.printStackTrace();
        }
  
    try {
        String dbURL = "jdbc:mysql://localhost:3306:employee";
    String userName = "root";
    String password = "admin";
        Connection connection = DriverManager.getConnection(dbURL, userName, password);
        Statement statement = connection.createStatement();
        String query = "INSERT INTO user Email, FirstName, LastName) VALUES  ('xx@gmail.com', 'Andrea', 'Stee');";
        int rowCount = statement.executeUpdate(query);
        
    } catch (SQLException ex) {
        Logger.getLogger(UserDB.class.getName()).log(Level.SEVERE, null, ex);
    }
    

anny suggestion to correct this error?
Does I need to add the connector somewhere in my application web?

>Solution :

It looks like the url should be updated like this.

String dbURL = "jdbc:mysql://localhost:3306/employee";
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading