Rajesh Sitaula Rajesh Sitaula - 1 year ago 61
SQL Question

jdbc connection msql error

java.sql.SQLException: No suitable driver found for jdbc:mysql@localhost:3306:emp
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.jdbd.connection.ConnectionDemo.main(ConnectionDemo.java:13)

here is my code

package com.jdbd.connection;

import java.sql.*;

public class ConnectionDemo {

public static void main(String[] args) {
// TODO Auto-generated method stub

//1. get a connection to database

Connection myconn = DriverManager.getConnection("jdbc:mysql@localhost:3306:emp","root","Dreamliner787");
//2.create a statement
Statement mystm =myconn.createStatement();
//3. Execute sql query
ResultSet myRs = mystm.executeQuery("select*from employee");
//4. process the result set
System.out.println(myRs.getString("last")+ "," + myRs.getString("first"));


catch(Exception e){



Answer Source

The error is either because your URL is wrong, or the JDBC driver is missing.

A JDBC URL typically looks like this jdbc:mysql://localhost:3306/mysql. I'm not sure why you have an @ in there. But that probably is the problem.

You can pinpoint if the problem is in the classpath by loading the driver like this.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download