0

Hey, so I get a Driver error when I try to connect to my local mysql db. My code is in a servlet as follows

Class.forName("com.mysql.jdbc.Driver").newInstance();
            Connection con=null;
            Statement smt=null;
            con=DriverManager.getConnection("jdbc:mysql://localhost:3306/sql?user=webusr&password=pass");

Thanks
M

3
Contributors
4
Replies
5
Views
10 Years
Discussion Span
Last Post by nschessnerd
0

dump the .newInstance(), it's superfluous.

Without knowing the actual error the cause of the problem will always remain guesswork.
But most likely you either don't have the correct driver or the database doesn't allow you to connect.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.