-1

I am a beginner in Java and I want to connect to a mysql database in Java. I have downloaded mysqlconnector.

I have extracted the files into tomcat lib paths but still I am unable to connect to database.

C:\tomcat\lib\mysql-connector-java-5.1.18-bin

I am using Eclipse and I have also installed wampserver.

Please help...

I want to connect to a database. How should I install my connector?

demongolem
  • 9,474
  • 36
  • 90
  • 105
Sandeep Roniyaar
  • 204
  • 1
  • 8
  • 26

3 Answers3

5

Add the mysqlconnector jar to your classpath, and use a simple JDBC java program to connect to the Database.

See http://www.mkyong.com/jdbc/how-to-connect-to-mysql-with-jdbc-driver-java/

Jay
  • 9,189
  • 12
  • 56
  • 96
1

Add the following to your Maven projects pom.xml file in the dependencies section:

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.30</version>
</dependency>

You may need a different version if so, look here for the correct one.

Mikkel Løkke
  • 3,710
  • 23
  • 37
0

Make lib folder in your project, copy jar in there, then right click on your_project and go to Properties->Java Build Path->Libraries and add your jar to project's class path

Evgeniy Dorofeev
  • 133,369
  • 30
  • 199
  • 275