Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6936549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:14:52+00:00 2026-05-27T12:14:52+00:00

When trying to connect to mysql I always get this error: java.sql.SQLException: No suitable

  • 0

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 mysql-connector.jar in the /WEB-INF/lib in my app. What else do I need to configure to make it work? Do I need to add something in web.xml? 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.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.mysql.client.ConnDb;

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

       Class.forName(driver).newInstance();
       con = DriverManager.getConnection(host+db, user, pass);
       return "Connected to Database";
     } catch(Exception ex) {
         return ex.toString();
     }    
   } 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:14:53+00:00Added an answer on May 27, 2026 at 12:14 pm

    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:

    • Connector/J documentation – Obtaining a connection
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to connect to MySQL database with Java and I get the
im getting this error while trying to connect a mysql database to an editor,
I am trying to connect to mysql and am getting an error. I put
I've been recently trying to connect to a hosted MySQL using Java but can't
I'm trying to connect to my localhost MySQL server via php in the terminal.
I am trying to connect to a remote mysql database but I get the
I'm running Linux Mint and trying to connect to mySQL this way mysql --port=3306
I'm trying to connect to the MySql database from a Java servlet. I'm working
I'm trying to connect to a different machine: $this->_connection = new PDO(mysql: host=MYSQL_SERVER; dbname=MYSQL_DATABASE,MYSQL_USER,
I am trying to connect to MySQL database from Java (MySQL is hosted in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.