Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to connect java and mysql using mysql connector java 5.1.12

I'm still a beginner in java. I dont have any idea on how to import the files that I have downloaded into my java class. Its in this path:

E:\Users\user\Downloads\mysql-connector-java-5.1.12

I don't know what to do with the files I extracted from the file that I have downloaded in the mysql site for me to connect my java application and mysql database.

I'm using Netbeans 6.8. And have also installed wampserver.

ive already check out This: Java: Trouble connecting to MySQL and this: Connecting to a MySQL database

But they don't seem to have answers on how to make use of the mysql java connector file from mysql site. Please help, thanks.

like image 355
user225269 Avatar asked May 31 '10 06:05

user225269


People also ask

How do you connect to a MySQL database in Java?

To connect to MySQL from Java, you have to use the JDBC driver from MySQL. The MySQL JDBC driver is called MySQL Connector/J. You find the latest MySQL JDBC driver under the following URL: http://dev.mysql.com/downloads/connector/j. The download contains a JAR file which we require later.

Can we connect MySQL with Java?

In Java, we can connect to our database(MySQL) with JDBC(Java Database Connectivity) through the Java code. JDBC is one of the standard APIs for database connectivity, using it we can easily run our query, statement, and also fetch data from the database.


1 Answers

Right click on your project in your project explorer and click on properties.

From there go to libraries -> add jar file then go to whatever .jar file you want to import.

That should add the jar file to your project classpath.

like image 183
Albinoswordfish Avatar answered Nov 03 '22 21:11

Albinoswordfish