Connect MySQL with your Java apps in ubuntu

First you need to install MySQL in ubuntu.For that ,run below command into your terminal.

sudo apt-get install mysql-server

After some moment system will ask for your database password.

Enter a password and remember it because it will need in future for access your database.



After that run below command and enter your user password:

mysql -u root -p



Now,it’s time to install mysql-workbench.

Run below command to install.

sudo apt-get install mysql-wokbench



Now from your dashboard search for “MySQL” and open it….



Click on Database and then connect Database.After that it will ask for your database password which you entered during installation.



Now create a new Schema.I created a schema with the name “Database”….

Screenshot from 2016-04-10 20-52-16


After that create a table.You can find that option under Database.See below screen shot for further help.



Now it’s time to insert data.You can do that manually or import data from a  file.

Screenshot from 2016-04-10 20-59-29


For import data from file right click on employee and click on “Select data import wizard”. After that select your file.




Now put mysql-connector.jar file in below location.

Download link:  mysql-connector.jar




Create a file like that and run your java code.

You will get output from your database…..!!



Referance Link:

  1. javatpoint
  2. ProgrammingKnowledge




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s