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.

2d

 

After that run below command and enter your user password:

mysql -u root -p

3d

 

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

Run below command to install.

sudo apt-get install mysql-wokbench

4d

 

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

5d

 

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

6d

 

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.

7d8d

 

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.

9d10d

11d

 

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

Download link:  mysql-connector.jar

 

12d

 

Create a Main.java file like that and run your java code.

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

 

13d

Referance Link:

  1. javatpoint
  2. ProgrammingKnowledge

 

 

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s