Thursday, July 9, 2009

Configure Eclipse and MySQL on Ubuntu Jaunty

I assume that Eclipse and MySQL has already been installed. I use Eclipse Ganymede (3.4.2) and MySQL 3.5.1. For installing MySQL on Ubuntu, see my previous post.

1. Download MySQL JDBC Connector (mysql-connector-java-5.1.7.zip/jar)

Choose a mirror and download from here

Extract the contents of the jar/zip to a folder.

2. In Eclipse, click Menu -> Window -> Show View -> Other. Expand the 'Data Management' option and select 'Data Source Explorer'.

Click OK. The Data Source Explorer tab will open.

3. In Data Source Explorer, right click 'Database Connections' folder and click New.

The 'New Connection Profile' dialog will open. Select 'MySQL' and click Next.

Most likely your Drivers drop down will be empty. If yes, then it is time to create a new Driver definition.

4. Click on the small 'New Driver Definition' icon next to the drop down.

5. In the dialog that opens, select MySQL JDBC Driver v5.1. 

6. Click Jar/List tab. You need to add the MySQL JDBC connector jar that you downloaded and extracted in step 1 above. Click Add JAR/Zip and select the mysql-connector-java-5.1.7.jar that you extracted. Click OK

7. Change the Database from 'database' to 'mysql' in both Database and URL fields.

8. Enter the password that you had provided during MySQL installation.

9. Click Test Connection and you should see a ping succeeded dialog.

10. Click Finish. Your database connection is successfully created. If you Expand the connection tree, you can see the database and tables etc.

Happy querying!

Install and setup MySQL on Ubuntu Jaunty

Here is how I installed MySQL 5.1 Community Edition on Ubuntu Jaunty:

1. Install MySQL

Goto Synaptic Package Manager and in quick search type 'mysql-server-5.1' (without quotes). From the list that will be provided, choose to install package with name mysql-server-5.1. It will show you all the dependencies and proceed to install.

Alternately you can use apt-get command.

sudo apt-get install mysql-server-5.1

1a. During the installation it will prompt for a password. Enter password of your choice.

1b. Confirm the password. Make sure installation completes successfully

2. Test the installation

To test the installation, type the following in Terminal.

mysql --user=root --password=yourpassword

"Welcome to the MySQL monitor. Commands end with ; or \ g.
Your MySQL connection id is 53
Server version: 5.1.31-1ubuntu2 (Ubuntu)

Type 'help;' or '\ h' for help. Type '\ c' to clear the buffer."

After this you should be able to see the prompt change to

mysql>

3. Use the mysql database.

mysql> use mysql;

"Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed"

4. Now see the tables present in the database

mysql> show tables;

This will display all the tables present in the database.

MySQL has been successfully installed.

In the next post I ll show how I configured Eclipse to talk to MySQL!

Sunday, July 5, 2009

Ubuntu Update Manager - Check/Uncheck All!

By default, the Ubuntu Update manager (Jaunty in my case), always has all the available updates checked (selected). But sometimes if I wish to select only a few of them, then unselecting the others was a real pain.

Here are two nice options that I found to Check All or Uncheck All the updates.

These options are available if you right-click on the checkmark/checkbox in the Update manager.

Handy!