No suitable drivers found for jdbc: mysql: // localhost: 8080 / kholofedb

advertisements

I have searched across the internet about this problem the whole of yesterdy... I am a beginner with JDBC, but the solutions provided here and other sites are not working for me.

I am using "mysql-connector-java-5.1.18-bin.jar" on Linux Mint 32 bit.. I am using Eclipse 3.8 ...I have installed mySQL-server and it is running ( I ran it using: sudo service mysql start )... at runtime I get this error

connecting to psysical database...

java.sql.SQLException: No suitable driver found for dbc:mysql://localhost:8080/kholofedb
  at java.sql.DriverManager.getConnection(DriverManager.java:604)
  at java.sql.DriverManager.getConnection(DriverManager.java:221)
  at com.psybergate.database.SimbleCode.main(SimbleCode.java:21)

here is my source code:

package com.psybergate.database;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

public class SimbleCode
{

    private static final String USER = "root" , PASS = "";

    public static void main(String ...args)
    {
        try {
            String connectionURL =       "dbc:mysql://localhost:8080/kholofedb";
               Class.forName("com.mysql.jdbc.Driver");
        //  Class.forName("org.postgresql.Driver");
            System.out.println("connecting to psysical database...");
            Connection conn = DriverManager.getConnection(connectionURL  , USER , PASS);

            Statement statement = conn.createStatement();
            System.out.println("Connection has been made");

            Scanner keyBoardScanner =  new Scanner(System.in);
            System.out.println("Enter table name:");
            String tableName = keyBoardScanner.nextLine();

            System.out.println("Creating table...");
            statement.executeQuery("create table " + tableName + " (name , age ,salary)");
            System.out.println("Table successfully created");
            System.out.println("Inserting data into the table ...");
            statement.executeUpdate("insert into " + tableName + "values (kholofelo , 21 , 9969696)");
        }
        catch (ClassNotFoundException | SQLException e) {

            e.printStackTrace();
        }

    }

}

Thanks in advance :)


Your connection URL should start with "jdbc:" not "dbc:"