Thursday, February 28, 2008

DB2: Remote Client Connection

I had a hard time connecting to a DB2 server after the remote client was installed. I'm not an expert on DB2, so I decided to notate this for others.

-From a command prompt, export a environment variables needed to run:

export DB2INSTANCE=db2inst1
export INSTHOME=/export/home/db2inst1

-Run DB2 and set the database catalog to the remove connection:


db2 => CATALOG TCPIP NODE UNIQUENODENAME REMOTE 192.168.1.10 SERVER 50000;

-Now, set database name to connect through the new node:

db2 => catalog database mydatabase as mydatabase at node UNIQUENODENAME

-And finally, connect to the database:

db2 => connect to mydatabase user username using password

Monday, February 25, 2008

Announcement: Release of "Practical Data Analysis and Reporting with BIRT"

I am pleased to announce the release of my first book "Practical Data Analysis and Reporting with BIRT". Also available from Amazon. After a long an grueling process, I am glad that it is finally complete and out. It is definitely a learning experience to write a book, so I hope you enjoy it.

Wednesday, February 20, 2008

BIRT: BIRT Reporting for Microsoft Access Using JDBC-ODBC Bridge

I'm speaking at EclipseCon 2008

Occasionally the question comes up asking how can one access a Microsoft Access database within BIRT. There are a number of different ways of doing this. The easiest is to use the Java JDBC-ODBC bridge, set up a ODBC connection on your system, and access it this way. This is the way that we will illustrate in this article. Additionally, you can also use a third part JDBC Access driver, and set it up as you would any other JDBC driver in BIRT. I have yet to find a good, free driver for this, although I haven’t looked either. If you were really looking for punishment, you could write your own driver, but that is a road I have no desire to go down since the simpler solution exists. Keep in mind, the limitation is that the Access database in question needs to be in a path that is accessible for the ODBC hosting system.

For this example, I am using the Northwind Sample Database located at http://www.microsoft.com/downloads/details.aspx?FamilyID=C6661372-8DBE-422B-8676-C632D66C529C&displaylang=EN.s

I installed the database to C:\TEMP\

Setting Up ODBC

Now I need to set up an ODBC connection to the Access database. I am using Windows XP Pro, so my instruction will reflect that, using the Classic theme. First, I go to the Start menu, under Control Panel. Under Control Panel, I click on the Administrative Tools icon. Then I click on the Data Sources (ODBC) Icon.

Now, because I want this to be accessible through to the System, I click on the System DSN Tab.

Next, I click on the Add button. In the dialog that pops up, I click on Microsoft Access Driver (*.mdb).

In the following dialog, I fill out the information. I name my database NorthWind, and put in a simple description.

Next, I click on the select button. This will bring up an older Windows 3.1 style file browser. I navigate to the C:\Temp folder, and choose the Northwind Sample Database.

From that point I am done, and hit OK and save this configuration. I test that this setup is valid by creating a dummy .UDL file on my desktop, and using the wizard to do a test connection.

Configuring BIRT

Now that I have an ODBC entry made, I need to configure BIRT to use the JDBC-ODBC bridge and connect it to this database. I create a new BIRT Report Project called JDBC-ODBC Access. Under this project, I create a new report called northwindEmployees.rptdesign.

In the report, I create a new Data Source by opening the Data Explorer tab, and right-mouse clicking on Data Sources and choosing New Data Source.

I name the Data Source NorthWind and specify that I want to use JDBC.

Next, I am presented with the JDBC Driver dialog. I need to configure the ODBC driver, which I have not done yet. Remember, that drivers are persistent in BIRT, so once I create it once, I don’t have to do this again, unless I wipe out my BIRT installation and delete the Eclipse folder. So I click on the Manage Drivers button.

From the Manage Drivers dialog, I click on the Add button.

BIRT needs a JAR file to work with. It is possible to use just the package path, but you would need to custom write something for that. Fortunatly, Sun does have the JAR containing the JDBC bridge in the JRE. Since I have JRE installed to C:\Program Files\Java\jre, I need to go to the lib folder there and find the rt.jar file. The rt.jar file contains the JDBC-ODBC bridge.

Now, I click OK and can see it has been added. Now I want to configure the default JDBC URL and Display name, so I click on the Drivers tab.

As you can see from the above screenshot, I already configured my defaults and display name. I used jdbc:odbc:mydb;UID=me;PWD=secret as my URL Template, and the name of my choosing. Now, I just click OK.

From my list of available drivers, I choose NorthWind, and for the URL, I change it to jdbc:odbc:NorthWind and test my connection.

Now, I create a simple Data Set to test this out. I just select the ID, name, and title of the employees from the Employee table. As you can see below, the table browser is available, so I know my connection is good.

Next, I drag my data set to the report designer, add a little bit of formatting, and I am done.

Tuesday, February 19, 2008

Eclipse: Sysdeo Tomcat Launcher

I have found myself in the position to work on a lot of J2EE based web solutions as of late. While not necessarily the area that I like to work in, it is paying the bills. So to continue with my Eclipse focused articles leading up to EclipseCon, I wanted to look at the Sysdeo Apache Tomcat launcher.

I like the Eclipse J2EE tools a lot. In fact, outside of BIRT, WTP is probably one of my more used toolsets in the Eclipse environment. There are just times where it is “overkill”. Also, every now and again I run into library loading issues when launching an app in Eclipse for a web environment where Sysdeo works around that. Sometimes you don’t want a huge Eclipse environment, so a small, 3rd part plug-in fits the bill nicely, and this is where Sysdeo comes into play..

http://www.eclipsetotale.com/tomcatPlugin.html

Installation:

Extract to Eclipse Plugins folder

That’s it, your installed and ready to rock and roll. There are additional steps involved with getting the DevLoader classes installed, but I never use those.

When done, you will see a set of icons for starting, stopping, and restarting Tomcat from within Eclipse.

Now, I need to set up my Tomcat location. I go to Window/Preferences

In the dialog, I go to the Tomcat section, and choose the options to locate Tomcat and the version I am using.

Next, I go to the JVM settings option and set up the Java Virtual Machine.

Now, it is ready for use.

Usage:

In the following example, I am going to import a web project I use as a baseline. The app consists of several JSP pages, and some core libraries. I will skip the steps of importing the actual application since they don’t apply, I will just jump into the configuration of the project for Tomcat.

The first thing I want to do is right-mouse click on my project, and go to properties. Under the property dialog, I want to go to the Tomcat section, and check the option that this is a Tomcat project. I also want to set up the context I will use.

When I hit OK, a new menu will appear for my project when I right-mouse click on it in the Project Explorer. From this menu, I want to choose to add the Tomcat Libraries to my project.

I also will choose the Update context definition to add this project to Tomcat. I do hit one other snag at this point before I can actually run my project. I need to manually copy my Java libraries and compiled class files to the Tomcat folder physically. I copy all the class structures under my BIN folder to /Shared/classes and all the JAR files to /Shared/lib. That takes care of it, now I can start Tomcat and work with my app.

I typically use Sysdeo for simple web apps, JSP based solutions, or solutions with simple classes. Anything more and I will fall back to using WTP.

Tuesday, February 12, 2008

Eclipse: Instantiations SWT Designer, GWT Designer, and RCP Developer

I'm speaking at EclipseCon 2008

Continuing on with my Eclipse centered articles, I am moving on to yet another set of tools I use quite often with Eclipse. Now, while I prefer not to do “product” endorsements, I do have to say I like using the Instantiations Window Builder series of products. In particular, I have been using the RCP Developer (well, more of the SWT Developer) and the GWT Designer products as of late. To put them into perspective, Instanatiations has a series of products that provide a simple, RAD type interface designers for a series of platforms, such as Swing, SWT, RCP and GWT. At last years EclipseCon, I won both a copy of GWT Designer and RCP Developer, which I mainly wanted to evaluate. RCP Developer, at the time, was my primary focus since I was tasked with building an RCP based application (I wrote on this previously 1, 2). However, I have since just been using the SWT Designer that came with it.

Figure 1. Designer Window

Figure 1 shows a screenshow of the Designer Window. This is where SWT Designer really gains its utility from. Having to hand code interfaces is a pain, so being able to quickly whip up an interface visually leads to cleaner visual designs and allows for rapid prototyping of visual interfaces. Here, you see the WYSIWYG designer that you would expect from most visual development environments nowadays, with a component palette next to a designer. You have components at your disposal, such as standard buttons, layout managers, text boxes, list and combo boxes, groupings, and menus. Here I have used a free form layout and built a simple interface, with buttons to connect to servers and edit server info, a code snippet insert below that, a large textbox in on the right, and the option to send a command to the a server. The designer also has the option to quickly test the interface without needing to compile or run (no functionality is provided), to quickly align components, and a quick little tool to externalize strings used in components. There is also a outline view to accurately select a correct component to work with and change properties. This is useful if you have many nested components.

Figure 2. Property Editor

Figure 2 shows the property editor. Here I have selected the Execute button. In the property editor, I can change things like the size, text displayed on the button, name of the button object, if it displays an image, and any other visual elements of the button.

Figure 3. Event handlers

If you double click on any component, or right-mouse click and choose add event handler, it will create a new event handler. Double-clicking adds a default handler (in the case of Buttons, widgetSelected). If you use the context menu, you have more control. In Figure 3, I have a widgetSelected event handler already, and am creating a mouseHover event handler. This will automatically import the correct class to use, and create a new instance of it in the addListener method, as seen in Figure 4.

Figure 4. Inserted Event Handler

Unlike with GWT Designer or RCP Developer, SWT Designer does not add a new launch command to Eclipses launch window, which is fine since SWT applications are Java applications anyway. It does, however, create a new Project type, and a number of new project file types, such as an Application Window, Dialog, and Shell.

Figure 5. New Types

RCP Developer provides similar mechanisms for RCP based applications, as does GWT Designer. The biggest differences are the inclusion of different launch mechanisms. With the GWT Designer, the launch mechanism not only launches, but will give you the ability to launch from within Eclipse and debug in Eclipse. With the new project wizard and this launch mechanism, it replaces the manual launch creator that I had previously illustrated.

Figure 6. GWT launch Mechanism

Figure 8. GWT Run Dialog

Figure 9 shows the designer for GWT Designer. As you can see, it is almost identical to the SWT Designer, except that it contains a GWT project, and uses the GWT Design components.

Figure 9. GWT Designer

In addition. GWT requires a little further configuration than either RCP Developer or SWT Designer in that you need to configure the location of the GWT libraries. This is available under the Window/Preferences dialog, under Designer/GWT.

Figure 10. Configure GWT Location

I will avoid my gripes about the license fees since they are more of personal gripes because I am cheap and have more or less spoiled myself with OSS offerings, and in no way reflect on the quality of the products themselves. Some programmers have to eat and pay the bills too, and these products have enabled me to build some cool little apps quickly, so I feel the price is worth it. If you’re at EclipseCon 2008, check out the Instantiations booth to see what else they have to offer. Maybe they will run the games they did last year to win a copy of the above mentioned products.

Sunday, February 03, 2008

Eclipse UML

I'm speaking at EclipseCon 2008

Since we are ramping up for EclipseCON 2008 at the end of March, I’ve been working a little more in Eclipse and getting a feel for the different Eclipse projects so I can attend some other presentations while I am there. I figured, since I am presenting again this year, I might as well take advantage of my presence there and learn a little more about the various Eclipse projects. Last Year I wrote about EasyEclipse and the PHP editor, which was a life saver for a PHP based project I worked on last year. This year, I want to focus on the Performance and Logging tools, and the UML tools.

I have made it well known in the past that I have been incredibly disappointed with the UML tools that are part of Eclipse. Previously they had no graphical interface, which was crap, and one would have to rely on third party plug-ins and projects. Of which many decent ones have surfaced, such as ArgoUML. But again, if something is to be part of the Eclipse Foundation, it should have a certain standard it should have to meet. I suppose I have been spoiled in the past by tools such as Rational Rose.

However, it seems that Eclipse UML has undergone some renovations in later versions. Finally, a graphical interface it present, and it is approaching a usable point for everyday projects. In the following example, I will walk through building some example diagrams.

Figure 1. UML Diagrams

Figure 2. Class Diagram

In Figure 2, I have put together a Class Diagram. This is a standard UML diagram showing the relationships between multiple classes, the properties and the methods of the classes. In this class diagram, I only showed associations and attributes. In Class Diagrams you have associations (linked to relationships), aggregations (whole/part relationships), and generalization/specialization (superclass/subclass relationships) associations.

Figure 3. Activity Diagram

I wont go into too much detail about the remaining diagrams, such as the Deployment Diagram. I had noticed the Activity Diagram has more activity types than in the last version of Rational Rose I had used (which was Rose 2000). I did notice several other diagram types that were absent, such as the Use Case Diagram, Swimline diagrams, and such. And while reverse engineering and code generation are noticeably absent, I feel that Eclipse UML is definitely heading in the right direction.