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

Recommended Answers

All 4 Replies

I use the port because my server is located on port 3306...

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.

Ahh thanks, it was newInstance

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.