- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Resolve java.sql.SQLException: No suitable driver found for localhost test?
You will get this type of exception whenever your JDBC URL is not accepted by any of the loaded JDBC drivers by the method acceptsURL. You need to mention the MySQL JDBC driver which is as follows −
The MySQL JDBC url is as follows −
jdbc:mysql://localhost:3306/test?useSSL=false
The prototype of acceptsURL is as follows −
boolean acceptsURL(String url) throws SQLException
The acceptsURL returns boolean that means if the JDBC driver understands the database URL it returns true otherwise false. It takes one parameter of type String which is a database URL.
The entire database URL connection is as follows. The syntax −
con = DriverManager. getConnection("jdbc:mysql://localhost:3306/yourDatabaseName?useSSL=false", "yourUserName", " yourPassword");
Example
The Java code is as follows −
import java.sql.Connection; import java.sql.DriverManager; public class AvoidSQLException { public static void main(String[]args){ Connection con = null; try { con = DriverManager. getConnection("jdbc:mysql://localhost:3306/sample?useSSL=false", "root", "123456"); System.out.println("Connection is successful !!!!!"); } catch(Exception e) { e.printStackTrace(); } } }
Output
The snapshot of code is as follows −
The following is the output −
Connection is successful !!!!!
The snapshot of the sample code is as follows −
- Related Articles
- Resolve error 1045 (28000) access denied for user 'root'@'localhost' (using password: YES)?
- Error 1046 No database Selected, how to resolve?
- Difference between Test-Path and Resolve-Path in PowerShell?
- No-Load Test and Blocked-Rotor Test on Single-phase Induction Motor
- What are the pre-conditions for Selenium Internet Explorer Driver or IE Driver?
- DOMException Failed to load because no supported source was found
- How to change user agent for Selenium driver?
- Difference between localhost and 127.0.0.1?
- Rename Root @ localhost username in MySQL?
- ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'localhost'?
- Jenkins for Test Automation
- Why are leaves suitable for photosynthesis?
- What is Selenium Internet Explorer Driver or IE Driver?
- Install wordpress on localhost with xampp server
- How does spring boot connect localhost MySQL

Advertisements