Gayathri rajakumar
Gayathri rajakumar

Reputation: 15

No suitable driver found -SQLException JDBC

I just started to learn JDBC. I'm trying to connect to my MySQL database. This is my code:

    import java.io.*;
        import javax.swing.*;
        import java.awt.*;
        import java.awt.event.*;
        import java.sql.*;
        public class Test2{
                public static void main(String[] args){
                        try{
                                Class.forName("com.mysql.jdbc.Driver");
                                Connection con = DriverManager.getConnection("jbdc:mysql://localhost:3306/data","root","
****");
                                Statement stmt = con.createStatement();
                                ResultSet rs = stmt.executeQuery("SELECT * FROM details");
                                while(rs.next()){
                                        System.out.println(rs.getString(1)+" "+rs.getString(2));
                                }
                                con.close();
                        }
                        catch (Exception e){
                                System.out.println(e);
                        }

    }
    }

I've checked other stackoverflow answers but they don't seem to resolve the problem. I've added the jar file correctly.I've also registered the drive.These were the answers I got when I searched the web.

Upvotes: 0

Views: 37

Answers (1)

Ivan
Ivan

Reputation: 8758

Looks like you have misprint in database URL. Should be

jdbc

instead of

jbdc

Upvotes: 2

Related Questions