Showing posts with label Getting Started. Show all posts
Showing posts with label Getting Started. Show all posts

Friday, October 5, 2007

MySQL Datasources - One thing leads to another ..

After installing CFEclipse, my next step was to create a few datasources. I have several databases lying around but for now I started with MySQL.

It turns out that setting up the MySQL datasource was an interesting experience for me. Not only because it was my first exposure to installing JDBC drivers for ColdFusion. I also learned a bit about MD5 checksums and cryptographic signatures in the process.

Since I am using Colfusion MX 7 and MySQL 5, I first read the instructions on the Adobe site Configuring a JDBC Driver for MySQL 4.1 or 5 for use with ColdFusion MX . Knowing I needed to download an updated JDBC driver first, I went the MySQL downloads section. There were several versions of the MySQL Connector J driver available. I decided to download a version 5.x driver, since the TechNote mentioned an incompatibility with MX7 and some of the 3.1.1x versions.

MD5 checksums and Signatures oh my!


On the download page I noticed two things: an MD5 value and Signature. Now I had heard of both, but must admit I had never used either. Thankfully the MySQL site provides a good description of how you can use the MD5 checksums and GnuPG signatures to verify the integrity of the packages you download. Since I am a curious type I decided to check both.

First I downloaded the GNU Core Utilities package for Windows after reading a helpful article on Peter Leung's blog mentioning the md5sum utility included in that package. Using the command line utility, I quickly verified the MD5 checksum of the MySQL download


  c:\download> md5sum c:\download\mysql-connector-java-5.0.7.zip \b7c9d9a274aa93af3d9111be567a5696 *c:\\download\\mysql-connector-java-5.0.7.zip


GnuPG (Oh great.. another acronym)


Next up was downloading GnuPG (GNU Privacy Guard) so I could verify the cryptographic signature. I started downloading the file when I noticed the checksum value listed was SHA-1 (not MD5). Fortunately the GNU Core Utilities package includes a utility for this too. Using sha1sum.exe I was able to verify the GnuPG file checksum.


   c:\download>sha1sum c:\download\gnupg-w32cli-1.4.7.exe\b806e8789c93dc6d08b129170d6beb9e1a5ae68f *c:\\download\\gnupg-w32cli-1.4.7.exe


After installing GnuPG, I tried to run gpg.exe from the command line, but got the infamous "not recognized as a command" error.


  c:\download> gpg
'gpg' is not recognized as an internal or external command, operable program or batch file.


I checked the README-W32.txt file and it confirmed the installer does not change the PATH environment variable. As I am lazy, I manually added the installation directory (c:\program files\GNU\GNUPG) to my PATH environment variable. That way I can run gpg.exe from the command line without having to type out the full path to the .exe every time I use it.

Next I copied the MySQL build key from the download site and saved it to a file: c:\download\mysql_pubkey.asc. Then I fired up another command prompt window and imported the key


  c:\download> gpg --import mysql_pubkey.asc


Next I downloaded the driver jar signature and saved it to: c:\mysql-connector-java-5.0.7.zip.asc. Then verified the signature with gpg. As you can see the verification was successful.


  c:\download> gpg --verify mysql-connector-java-5.0.7.zip.asc
    gpg: Signature made 07/18/07 14:31:37 using DSA key ID 5072E1F5
    gpg: Good signature from "MySQL Package signing key (www.mysql.com) <build@mysql com="">



Wow, I have learned all this great stuff and have not even created the datasource yet.

Creating a MySQL Datasource (Finally!)


Now that I had verified all of my download files, it was time to install the driver. I unzipped the archive and immediately noticed more files than I was expecting



But I did not panic. The TechNote said to look for a file name like: mysql-connector-java-3.{n}-bin.jar. Since I had downloaded a version 5.x driver, my jar happened to be named mysql-connector-java-5.0.7-bin.jar. So I copied it into the cf_root/WEB-INF/lib directory and restarted ColdFusion. After the server restarted, I created my datasource according to the instructions. Here are the settings I used


Datasource Name: MySQL5DSN
Driver: Other
JDBC URL: jdbc:mysql://127.0.0.1:3306/sakila
Driver Class: com.mysql.jdbc.Driver
Driver Name: com.mysql.jdbc.Driver
User Name: testUser
Password: ********

Note, my database is running on port number 3306 and the database name is "sakila"


After entering the settings, I clicked the submit button and received this lovely error



Turns out the MySQL service was not running (duh!). After starting the service, and configuring my firewall to allow communication between CF and MySQL, the datasource verified successfully.

The only thing left to do was create a test page in CFEclipse. I ran it and eureka, it works!



I know some of this has nothing to do with either ColdFusion or MySQL, but I found it interesting and hope some of you might as well. As always, comments/suggestions/corrections are welcome.

... we now return you to your regularly scheduled ColdFusion programming.

...Read More

Sunday, September 30, 2007

Getting Started - Part II (Installing Eclipse / CFEclipse)

So I finally installed Eclipse. In the end I was triumphant, but the install was a little rocky. First I want to stress that most of this was not due to a lack of solid documentation on the Eclipse site. In my zeal to get started, I overlooked a few things. As I believe we learn as much from failures as we do successes, I decided to share the whole gory tale, warts and all.

First I visited the Eclipse download page and was surprised to find several versions of Eclipse available. I reviewed the comparison of the available packages and decided to install the Eclipse IDE for Java Developers.




I knew a Java runtime environment (JRE) was required to use Eclipse. But fortunately I had already installed a version a while back for another application. Armed with that knowledge, I was ready to begin installing.

I downloaded Eclipse and extracted the files to c:\eclipse. Then I double clicked c:\eclipse\eclipse.exe to launch the application and voila, the splash screen appeared. Eclipse prompted me to select a workspace. Since I prefer not to have my files strewn over multiple directories, I created my workspace in c:\eclipse\workspace.


After clicking OK, Eclipse launched the welcome screen. I opened the workbench and all seemed well, so I moved on to the next step: installing the CFEclipse plugin. I installed the CFEclipse plugin using the instructions for the built-in installation and update tools


1. Select the "Help->Software Updates->Find and install" menu option
2. On the screen that is displayed, select 'Search for new features to install' and click the 'Next' button
3. Now click the 'New Remote Site' button
4. Enter a name for the update site, for example "CFEclipse". In the URL box, enter "http://www.cfeclipse.org/update" and click the OK button
5. You should now have a 'CFEclipse' node in the 'Sites to include in search' box.
6. Tick the 'Stable CFEclipse' box and click 'Next'
7. Eclipse will contact the CFEclipse site and retrieve the list of available plugins. Tick the plugin with the highest version number and click 'Next'
8. The next instructions are self-explanatory, agree to the license, install the software and restart Eclipse
Once Eclipse has restarted CFEclipse should have been successfully installed


During the installation, I did note there was no 'Stable CFEclipse' option in my version. So I just accepted all of the defaults and followed the rest of instructions. The version I installed was CFEclipse 1.3.1.5, which includes CFUnit and Frameworks


After the install was complete, I went to open the CFEclipse perspective so I could create my first CF project.

  • Window -> Open Perspective -> Other -> CFEclipse [OK]


That is when I hit my first snag. Instead of opening the perspective, I received the error "Problems opening perspective 'org.cfeclipse.cfml.perspective.CFML'".



Huh.. what is wrong with my perspective? Having no clue what the error meant, I did some googling and discovered there is an issue with involving Eclipse and JRE 1.4.2. The suggested solution was to install either JRE 1.5 (or 1.6). Now I was relatively certain I did not have 1.5 or higher installed. But that did not concern when I first read the Eclipse requirements because they stated 1.5 was recommended not required. Well, I guess I took a gamble and lost. I checked my JRE version and I confirmed that I was indeed using JRE 1.4.2

  • Window -> Preferences -> Java -> Installed JREs




Off I went to www.java.com to download a newer JRE. I chose the more recent version JRE 1.6. 0_02. Though confusingly it was referred to as Version 6 Update 2. After installing it, I went back into Eclipse to add 1.6. 0_02 to my list of Installed JREs.

I clicked[Add] then navigated to the directory where I had installed JRE 1.6. In my case it was D:\Program Files\Java\jre1.6.0_02 but yours may differ.



I clicked [OK] and back in the main window I checked the box next to JRE 1.6.0_02 and clicked [OK] again. Almost done, I thought to myself. Feeling triumphant I went to open the CFEclipse perspective. But to my surprise I received the same darn error!

Then I realized the Eclipse was probably still loading with the old JRE, since I had not uninstalled it. With a little help from wiki.eclipse.org I discovered I could specify which JRE Eclipse should use in the eclipse.ini file. So I made a backup of c:\eclipse\eclipse.ini, then opened the original with notepad and added the "vm" parameter. Once I saved the eclipse.ini file and re-started Eclipsed, presto! The CFEclipse perspective opened like magic.


  -vm d:/program files/java/jre1.6.0_02/bin/javaw.exe -showsplash org.eclipse.platform --launcher.XXMaxPermSize 128M -vmargs-Xms40m -Xmx256m


Well, that is enough for now. Hope this helped someone or at least provided some entertainment ;) For those of you that prefer a less rocky path, there are some excellent screen casts on the Eclipse site, under "Tutorials and Help"

Installing and Using the Eclipse IDE for Java Developers
Adding Features from the Europa Discovery Site
Test First Development using Eclipse


As always, suggestions, comments, corrections and commiserations are welcome ;)

...Read More

Getting Started - Part I (Choosing my IDE)

Where to begin? So far I've installed the ColdFusion Server (Developer Edition). I won't cover that process here since there are a wealth of good tutorials on the web that describe the installation process. Well.. that and the fact that I performed the installation (several of them) some time ago, so its not as fresh in my mind ;) My next step is to choose an IDE.

For development, I decided to use Eclipse with the CFEclipse plugin. I have nothing against Dreamweaver, but decided against using it as my IDE for several reasons.

As I understand it, Dreamweaver is offered under a 30-day trial license. I wanted the flexibility of learning an IDE at my own pace. So in the event that I'm unable to fully explore the application within that time period, I would not have to switch IDE's mid-stream. I also intend to delve into java and explore how I can incorporate it into my ColdFusion code. So overall it seemed like Eclipse would be better suited to my development needs.

Truthfully I do not have much experience with open source software. So the thought of using Eclipse is both exciting and a bit daunting. But time to dive in an see what all the fuss is about.

...Read More

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Header image adapted from atomicjeep