Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Eclipse IDE - Unable to connect to mysql database(MYSQL database connector to Eclipse IDE)
Eclipse IDE - Unable to connect to mysql database [message #1821618] Mon, 17 February 2020 13:58 Go to next message
Tania Das is currently offline Tania DasFriend
Messages: 2
Registered: February 2020
Junior Member
I followed the instructions of downloading the connector driver (version 8.0.19) of MYSQL database (5.1) and getting connected to eclipse IDE(13 version), but shows the error message is

java.sql.SQLException: No suitable driver found for jdbc:mysql//localhost:3306/employee
at java.sql.DriverManager.getConnection(DriverManager.java:700)
at java.sql.DriverManager.getConnection(DriverManager.java:258)
at jdbcdemo.Driver.main(Driver.java:14)

I tried to map the driver connector file from the reference library to the project file, but still gives the error.

Please could you help me connected to mysql database?
If there is any way of explaining it in a better way, then please let me know.

I have attached the java file that shows the connection steps taken.

package jdbcdemo;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class Driver {

public static void main(String[] args) {

try{
//get connection to database
Class.forName("com.mysql.cj.jdbc.Driver");
Connection myConn=DriverManager.getConnection("jdbc:mysql//localhost:3306/employee","root", "Akshitabogam#24");
//create statement
Statement myStmt =myConn.createStatement();
//execute a sql query
ResultSet myRs = myStmt.executeQuery("select * from employeesample");
//process the result
while (myRs.next()){
System.out.println(myRs.getString("age"));
}
}
catch(Exception exc){
exc.printStackTrace();
}

System.out.println("Connected?");
}

}
  • Attachment: Driver.java
    (Size: 0.80KB, Downloaded 372 times)
Re: Eclipse IDE - Unable to connect to mysql database [message #1821619 is a reply to message #1821618] Mon, 17 February 2020 14:03 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

While this sounds more like a general Java programming question than one specifically to do with Eclipse, could you clarify what "I tried to map the driver connector file from the reference library to the project file" means within the context of Eclipse, and its UI?

_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: Eclipse IDE - Unable to connect to mysql database [message #1821622 is a reply to message #1821619] Mon, 17 February 2020 14:44 Go to previous messageGo to next message
Tania Das is currently offline Tania DasFriend
Messages: 2
Registered: February 2020
Junior Member
I first downloaded the driver connector jar file and saved it in the folder.
After creating a database project in Eclipse IDE, I used the build path option to get the driver connector file. And the driver file gets downloaded in the reference library folder under the project file name database.

So I am trying to ensure that I have the driver connector file under the source project name database, before I run the program. I watched a few videos of getting their mysql database connected to their eclipse SE IDE and doing the exact same setps but for some reason, I am unable to get the driver connected to the eclipse IDE
Re: Eclipse IDE - Unable to connect to mysql database [message #1830505 is a reply to message #1821622] Tue, 28 July 2020 01:19 Go to previous messageGo to next message
Roger Medlen is currently offline Roger MedlenFriend
Messages: 1
Registered: July 2020
Junior Member
Was this ever resolved?
I'm having the exact same issue. It's as though the inclusion of the .jar file isn't being recognized. Thanks in advance.
Re: Eclipse IDE - Unable to connect to mysql database [message #1830506 is a reply to message #1830505] Tue, 28 July 2020 02:37 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

Shouldn't the mysql part of that URL be followed by a :, before any /s, i.e. jdbc:mysql:/localhost:3306/employee , rather than was shown? It's not part of the hostname, so it's part of the "protocol."

_
Nitin Dahyabhai
Eclipse Web Tools Platform
Previous Topic:Programmatically call 3rd party plugin editors
Next Topic:I need help in the Tutorial i am doing
Goto Forum:
  


Current Time: Thu Apr 25 15:33:14 GMT 2024

Powered by FUDForum. Page generated in 0.08368 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top