user1035079 user1035079 - 1 month ago 5x
MySQL Question

java.sql.SQLException: No suitable driver found for localhost test

When trying to connect to mysql I always get this error:

java.sql.SQLException: No suitable driver found for localhost test

I already included the
in the
in my app. What else do I need to configure to make it work? Do I need to add something in
? I'm not using the appengine.

Here is my code in the server:

package com.mysql.server;

import java.sql.Connection;
import java.sql.DriverManager;

import com.mysql.client.ConnDb;

public class ConnDbImpl extends RemoteServiceServlet implements ConnDb {
public Connection con;
public String tryConn() {
String host = "localhost";
String db = "test";
String driver = "com.mysql.jdbc.Driver";
String user = "root";
String pass = "pwd";

con = DriverManager.getConnection(host+db, user, pass);
return "Connected to Database";
} catch(Exception ex) {
return ex.toString();


You will get this exception when the JDBC URL is not accepted by any of the loaded JDBC drivers as per the Driver#acceptsURL() method. You actually forgot the JDBC driver specific URI prefix. For the MySQL JDBC driver this is jdbc:mysql://. The full connection URL should look like this:

con = DriverManager.getConnection("jdbc:mysql://localhost/test", user, pass);

See also: