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 47 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: 3707
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 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
Previous Topic:How to debug in single path a bash shell invoking perl .pl, which in turn invokes python .py?
Next Topic:XMLUtils.getNode
Goto Forum:
  


Current Time: Fri May 29 08:33:17 GMT 2020

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

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

Back to the top