0

I have Eclipse Indigo on Mac Os X and I have downloaded mysql connector (version 5.1).
I have added the jar to the project and I am using this code:

public class Test 
{
    public static void main (String[] args)
    {
        try {
        String url = "jdbc:msql://200.210.220.1:1114/Demo";
        Connection conn = DriverManager.getConnection(url,"","");
        Statement stmt = conn.createStatement();
        ResultSet rs;

        rs = stmt.executeQuery("SELECT Lname FROM Customers WHERE Snum = 2001");
        while ( rs.next() ) {
            String lastName = rs.getString("Lname");
            System.out.println(lastName);
        }
        conn.close();
    } catch (Exception e) {
        System.err.println("Got an exception! ");
        System.err.println(e.getMessage());
    }
    }
}

When I try to execute the program I get this exception:

Got an exception! 
No suitable driver found for jdbc:msql://200.210.220.1:1114/Demo

My question is : how to install the driver? What else should I do?
And once installed the driver, how do I get my database URL (I am using mysql 5.5)?
I haven't found a valid guide on the web, they're all too specific.

2

4 Answers 4

1

Your JDBC connection URL is not correct, refer to the official documentation to check the required format for the URL .

In your case the URL will become :

String url = "jdbc:mysql://200.210.220.1:1114/Demo";
Sign up to request clarification or add additional context in comments.

Comments

1

you're missing the "y" in jdbc:mysql

1 Comment

correct the jdbc connection string and if you have the jdbc jar in your project classpath then it should work properly.
1

You are using MySQL, the URL should look like this:

jdbc:mysql://200.210.220.1:1114/Demo

may be, review the IP and PORT.

Comments

0

You may have added the jar to your project but have you also added it to the project classpath? Having the jar exist as a file in your project won't solve the problem. The jar file is clearly not accessible to your program. Right click on your project -> Build Path -> add the jar there.

Database URL looks ok, assuming you have the right host address and port number.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.