Mysql JDBC


Development environment

  1. JDK 1.8 Downloads
  2. Eclipse Mars Download
  3. MySql  download

Required jar files


Maven dependencies

In order to run the example; simply follow following steps:

Step 1 Create Java Project

Launch Eclipse IDE; Create new Java Project by going to File -> New -> Others… -> Java Project. Choose any project name you want then click Finish.

Step 2 Create Java Class

Copy the code below to clipboard; Select src folder in your project; Press CTRL + V; Eclipse IDE will automatically create package & class file with the code that’s pasted from clipboard.

Step 3 Configure Build Path…

  1. Download Connector/J; and then to unpack it.
  2. Create lib folder by right click to the project select New -> Folder. Copy mysql-connector-java-5.1.37.jar file from the unpacked folder; and paste to the lib folder.
  3. Right click to the project; select Build Path -> Configure Build Path… Select Libraries tab; click Add Jars… Select the 2 above files then click Ok.  Click Ok to finish the configuration.

Step 4 Run the application

Right click to the class; select Run As -> Java Application.


In case you forget to add the MySQL Connector/J jar, you will see this: