Subversion on Mac OS X

My workplace is switching from CVS to Subversion for source-code version control so I need to pick up Subversion rather quickly. It took me awhile to get comfortable developing with CVS and now I need to learn stuff all over again. I even have scripts setup to help with the deployment of my project using CVS -- now they need to be modified to work with Subversion. Oh well, I'm sure its for the best.

I've been reading the awesome, and free, Subversion book a lot lately and it has really helped with my understanding of how Subversion works. Since Subversion is not installed on OS X by default, we need to install it before using it from the command line. I downloaded the easy-to-install Subversion .dmg distributed by Martin Ott.

After running the .pkg-installer I was able to run svn help from the command line to confirm it was installed properly. If that command doesn't work after installing, you may need to add this line to the .profile file (in your home directory):

export PATH=$PATH:/usr/local/bin

Now you should be able to run all the SVN commands from your Mac OS X command line. If you prefer a GUI interface to SVN, check out svnX. I do all my development from within Eclipse, so I'm using an SVN plugin for Eclipse called Subversive. I prefer it over the more commonly known Subeclipse plugin because Subversive has a friendlier, and seemingly more configurable, interface.

Checking out a project from the command line over SSH is really simple, however while searching Google I was unable to find this "simple" answer. If I had found the free Subversion book before searching for this answer, I probably wouldn't be writing this:


svn checkout svn+ssh://svn.dev82.org/projects/myproject

That's it! The syntax for checking out a project is very similar to CVS, however SVN has the concept of "URLs" to specify the location and type of connection to your repository. If you have SSH Client Keys setup, you can run SVN commands over SSH without the password prompt (which is necessary for the deployment scripts I use).

Installing the Eclipse SQL Explorer Plugin on Mac OS X

There is a great plugin for Eclipse called SQL Explorer, which "is a thin SQL client that allows you to query and browse any JDBC compliant database". I have a local LAMP (or in this case, MAMP) environment setup on my Mac for development purposes. Up until now I have been using phpMyAdmin through an external web browser to view/edit the MySQL database (Eclipse's built-in web browser sucks -- I cannot even copy/paste from it!). Since I do everything else from within Eclipse, moving outside the Eclipse window just to view tables/data in the database really interrupts my work-flow (not to mention the distractions that come with using a web browser 😉 ).

SQL Explorer is really nice, once you get it working. I assumed it would be as simple as downloading the plugin and creating the connection to my local MySQL database -- but that didn't work. You can download and manually install the plugin, but choose to use the built-in Eclipse Install and Update functionality to download and install the plugin. Here is how it's done:

Download and Install Eclipse SQL Explorer Plugin

  1. From within Eclipse, choose 'Help -> Software Updates -> Find and Install' from the menus
  2. Choose the 'Search for new features to install' option and click Next
  3. Click 'New Remote Site', enter 'SQL Explorer' in the Name field and 'http://eclipsesql.sourceforge.net/' in the URL field and then click OK
  4. You should now see 'SQL Explorer' in the list of 'Sites to include in search'
  5. Uncheck everything except 'SQL Explorer' and click Finish
  6. A new screen should open which allows you to select 'SQL Explorer'. After selecting it, click Next

The SQL Explorer plugin should now be installed and available as a new perspective. You can start using it by selecting it in the Open Perspective list (Window -> Open Perspective -> Other...). Once you have opened the SQL Explorer, you will need to add a new connection. In the Connections tab, click the 'New Connection Profile' icon or right click anywhere inside the empty list and choose it. This will open the 'Create New Connection Profile' window.

This is where there is no documentation explaining what is really needed to connect to a MySQL database. You would think it would be as simple as selecting the MySQL Driver from the list, entering your database connection information and saving the connection. But upon doing this, I received the following error:

I don't know about you, but I have definitely seen more informative error messages than com.mysql.jdbc.Driver. After a little research, I discovered that we actually need to install the MySQL JDBC driver before using SQL Explorer to connect to a MySQL database. I didn't see this information anywhere in the SQL Explorer documentation or on the website. The fact that the Create New Connection window shows me a huge list of database drivers to choose from is very misleading!

Before we add the new driver, we need to download the MySQL JDBC Connector. You will want to copy the mysql-connector-java-5.0.8-bin.jar file somewhere permanent, since the new driver we create will look for for this file whenever we connect to a MySQL database.

Download Connector and Create MySQL JDBC Driver

  1. Download the MySQL JDBC Connector, extract and save the mysql-connector-java-5.0.8-bin.jar file some place permanent (I stored it in my /Applications/Eclipse/ directory)
  2. Open the 'Create New Connection Profile' window in SQL Explorer, click the New Driver button
  3. On the 'Create New Driver' screen fill in the Name field with something like 'MySQL JDBC Driver'
  4. In the Example URL field fill in the following: jdbc:mysql://[<:3306>]/
  5. Click the Extra Class Path button
  6. Click Add and then select the mysql-connector-java-5.0.8-bin.jar file you downloaded
  7. Click the List Drivers button. This should automatically fill in the Driver Class Name field at the bottom with 'com.mysql.jdbc.Driver'

At this point, you should have a window that looks like this:

Click the OK button. This will bring you back to the 'Create New Connection Profile' window. Now you should be able to select your new 'MySQL JDBC Driver' from the list of drivers, fill in the URL field with something like 'jdbc:mysql://localhost:3306/test_database', and enter your MySQL Username and Password details (if you're using MAMP, the defaults are root/root). Click OK and then double click on the new connection in the Connections list. Assuming your MySQL database is running and the connection details are correct, you should see the Database Structure tab populate and allow you to view the contents of your database.

For those who might want to know exactly what versions of software I am using, here is the list:

Mac OS X 10.4.10 on a MacBook Pro
Eclipse 3.2.2
SQL Explorer plugin 3.0.0.2006
MySQL JDBC Connector 5.0.8

I've only started to explore the possibilities of what can be done with SQL Explorer, but I can already tell it will make my development process much smoother. I was surprised that there wasn't more readily available documentation explaining how to do what I have explained here, but hopefully someone will find this mini-tutorial useful.

A sore body and a new collaboration

I am incredibly sore from Monday and Tuesdays workouts. Ravi wanted to do arms on Tuesday, so we did workout C instead of workout B. That was probably a bad idea, because it didn't give my chest or arm muscles enough time to recover from the previous day's workout. I'm mostly feeling it in my triceps and obliques -- when I lift my arms over my head.

I've been going over Thea's place on Wednesday nights and tutoring him in PHP programming. The past few sessions haven't been very productive, but thats because I had to get his programming environment setup properly. I installed XAMPP and Eclipse (with the PHP plugin). We decided today that we're going to work on a project together; a web retail store which will allow Wholesale Floral Corp to sell discontinued items to the public. Building this application together will be excellent experience for the both of us. We're going to use the Smarty PHP template engine and stick to Object-Oriented programming as much as possible. To collaborate our development work we're going to use my home CVS server.

My Text Editor of Choice

First a little history:

I first started programming using the MS-DOS Edit program while programming QBasic (I know, I should have learned C first, and I regret it!). Edit was the first text editor I ever used.

When I started writing HTML web pages, I used Microsoft's Notepad. It wasn't until many years later that WYSIWYG editors came out and made creating HTML pages as simple as writing a letter in Microsoft Word. I learned to use Macromedia's Dreamweaver when I started to manage hundreds of separate HTML files (Microsoft's FrontPage is crap!). A WYSIWYG editor is a godsend if you have lots of tables to work with. However, I've learned to use CSS styling in place of tables, so that doesn't even apply to me. Continue reading