Thursday, June 04, 2009

DB2 Stored Procedure Hell

I'm a systems integrator and have no desire to understand everything at the lowest level of detail possible. I understand things conceptually and know where to find manuals to help me complete tasks but I have not got the time to understand every technology going.

Today, I had my first need to create a DB2 Stored Procedure and use it. In 20 years, I've never had to do that - which seems strange even to me. I've always known about them and understood their power but it has always been "someone else" who has created them and consumed them in their applications. Remember... I integrate systems?

So - how hard can it be? Well, my good friend Google helped when I asked for information on "creating a stored procedure". A tonne of links - must of which assumed that I would be using some heavyweight IDE. I'm a command-line kind of guy though!

It was at that point that I thought that even though this is a simple task and I'm fairly convinced I'll be able to do this within minutes rather than hours, I still figured I should maybe record the process I went through. The reason? I'm fed up being sent down blind alleys by trash on the internet.

I create a myfirstproc.sql file with the following contents:

CREATE PROCEDURE MYFIRSTPROC
(IN username CHAR99), IN disclaimer INT)
LANGUAGE SQL
BEGIN
IF disclaimer = 1 THEN
INSERT INTO USER (USERID, DISCLAIMER) VALUES (username, 'Y');
ELSE
INSERT INTO USER (USERID, DISCLAIMER) VALUES (username, 'N');
END IF;
END @
Straightforward, eh?

I applied it (eventually) using the db2 -td@ -vf myfirstproc.sql command.

Next, I wanted to use IBM Tivoli Directory Integrator to invoke the stored procedure. I created a passive JDBC connector called manageDB and created a script as such:

var con - manageDB.connector.connection;
command = "{call MYFIRSTPROC(?,?)}";
try {
cstmt = con.prepareCall(command);
cstmt.setString(1, "H12345678");
cstmt.setString(2, 1);
cstmt.execute();
cstmt.close();
}
catch (e) {
task.logmsg(e);
}
Now, that all looks quite neat but there is a bug in the code. When I ran the code I received a "Method Not Yet Supported" message. Now, what can you imagine would cause such a message? My first thought was that maybe I was using an out-of-date driver so I decided to get the latest one. This in itself is a major undertaking as anyone who has tried to find anything on the IBM website will testify! Certainly searching for db2jcc.jar (as I did) did not take me to anywhere from which I could download it!

The new JAR file was put in place and the routine executed again. "Method Not Yet Supported" again. Now - that's quite frustrating! Searching for "Method Not Yet Supported" yields information on how the method I'm calling isn't supported. In other words, a useless message!

Trawling through the code, it wasn't immediately obvious what the issue could've been. Not obvious because the code looked syntactically correct (and in any case, if there was a coding error, surely I would've been presented with an appropriate error message).

Well, the eagle eyed amongst you will notice that the original code above was attempting to set parameter 2 to a value of 1 as a string. Converting this to a setInt statement rectified the problem! The resulting code:

var con - manageDB.connector.connection;
command = "{call MYFIRSTPROC(?,?)}";
try {
cstmt = con.prepareCall(command);
cstmt.setString(1, "H12345678");
cstmt.setInt(2, 1);
cstmt.execute();
cstmt.close();
}
catch (e) {
task.logmsg(e);
}
So, why share this with you? Well... I'm not I guess. I've written this more as a reminder to myself. The important following lessons have been learned:
  • Don't trust the information on the internet - it's typically out-of-date (just as this article will be as soon as I hit the publish button?)
  • Don't trust error messages - they've been constructed by developers and could be meaningless
  • Good luck with searching that IBM website
  • Everything is possible with a smidgin' of perserverance

Tuesday, May 19, 2009

The Problem With The Web....

... is currency!

I have a Windows 2003 Server VMWare image within which I build demos and test environments. (I do have a SUSE Linux v10 demo environment for real stuff but sometimes customers want to see applications running happily inside Windows). The latest installation I attempted chucked a hissy-fit when it came to calculating disk space. It wanted 10GB and I only had 7GB on my C:!

Resolution 1
I thought, no problem... I'll add a new virtual disk, give it 20GB and call it my D: drive. After just a few moments, my disk was available and I restarted the installation. But guess what... it refuses to install anywhere other than C:

Resolution 2
Disappointed, I figured I'll just resize my primary partition. And the fun began...

VMWare Workstation 6.5 comes with vmware-vdiskmanager.exe which allowed me to resize the virtual disk. (For information, I took it from 15GB up to 30GB). But, of course, that doesn't help unless I resize the partition as well.

Time to boot Windows 2003, bring up a command prompt and type diskpart in order to resize. But diskpart will refuse to resize a bootable partition! Doh!

That's OK though - I have a copy of Easeus Partition Manager! Try to install it and it said "You've got Windows 2003 Server! Please purchase the Server Edition of EPM".

hmm.... seems my EPM version is for non server based Windows installations. Off to the Easeus website then and I found that the server edition will set me back $150!

Google Time
I'm not paying $150 for a one-off resize! Someone must've done this before so let's give Google a bash.

It seems that people have had this problem before and I study their techniques for resolving the problem. I find 3 possible options:

Option 1 - Knoppix with QTParted
I download 700mb of a Knoppix Live (as instructed) and boot my VM using the ISO image. But... the latest version of Knoppix doesn't ship with qtparted any more. The instructions I've found on Google are, sadly, out-of-date.

Option 2 - Knoppix with ntfsresize
Fortunately, my version of Knoppix does have ntfsresize so I give it a go. It says that it will resize my C: but only if the partition has been resized first so I have to use FDISK. I launch fdisk and tell it to increase the number of cylinders to be used on that partitioni and it point-blank refuses. More Googling tells me to delete the partition and recreate - but that just merely destroys all my data (I know - I did it - but only after I'd backed up my partition - phew!)

Option 3 - vmware converter
Next, I follow the procedure sfor vmware converter. I say follow... I did download the converter (which took a while) and installed it (which took longer) and then ran it. The screens didn't offer up the options that were describe by my Google search! It seems that my version of converter is a lot more recent than the one described in the web article and the functionality I'm looking for no longer exists.

Option 4 - GParted
My final options was GParted - a live bootable ISO image that claims to do the job. I searched for it, found it on Sourceforge, hit the download button and..... NOTHING. Doesn't exist or at least it's offline for the time-being.

Time to give up and go to bed

Next morning, though, I tried to retrieve GParted again and thankfully it was now available. Downloaded it, booted, clicked a couple of buttons and my partition was resized perfectly.

The Moral
This was a very simple procedure and it did not require too much effort to achieve it... in the end. The problem is that this is just the latest example of the web sending me off on tangents because the information that I found is no longer relevant or out-of-date. Unfortunately, the information has been round long enough to find itself high up on the search results yet the up-to-date, relevant stuff was actually tricky to find.

Don't get me wrong, I'm a big fan of Google but as the web clogs up with more irrelevant information, I'm finding it more and more difficult to get the information that I need.

It would be great if the custodians of information would clean-up their act. Maybe a "Best Before" date ;-)

Wednesday, May 13, 2009

Self Promotion

I had the pleasure of attending a wonderful wedding at The Manoir last weekend.

I was fortunate to be asked to be "Best Man" at the event. Of course, I had to give a speech which was quite nerve-racking but it went down a storm.

Speaking at such an event is a great way of getting introduced to people. Everyone came to me after I had spoken to congratulate me and tell me how much they enjoyed what I had to say. Would they have been so eager to speak to me if I had been a mere mortal at the event?

So lot's of strangers spoke to me and the usual conversation ensued: "How do you do?"; "Nice weather, isn't it?"; "What do you do for a living?".

Normal run of the mill stuff you might think and you'd be right. However, I did get some interesting questions:
  • How do you get business and how do you promote yourself?
  • How do you keep on top of your reputation?
  • Would you be my friend on Facebook?

I guess the answer to these questions differ depending on the business that you are in, but for me, getting business and self-promotion is all about the following:
  • Reputational enhancement through constant delivery
  • Ensuring the right people are made aware of the delivery success
  • Promotion through social networking (LinkedIn, Twitter, Website, Blog, etc.) and being careful what I say on each medium
  • Standing up in front of people and speaking - getting noticed

Indeed, giving a Best Man's speech, while important for the recently married couple in question, is another means of self-promotion I guess - unless you make a mess of it!

So how do I keep on top of my reputation? Time... might just take a few minutes each day to post to Twitter; maybe 15 minutes to write a blog entry (like this?); and just a few moments each month to check that my website is still relevant.

It doesn't take much and there really is no excuse for people allowing their reputation to waver!

As for being a friend on Facebook? Again, it might be reputationally damaging for me to be friends with certain people - I don't do too many randoms! Gain my trust first please.

Friday, May 01, 2009

Identity Mapping

 got to thinking the other day about my online "presence". I do the Facebook thing, the Twitter thing, the LinkedIn thing and I have a .tel domain now!

Some of these "things" talk to each other. Twitter feeds Facebook and Plaxo, for example. I thought it would be quite cool to try to map these services to show the linkages (and it was more difficult than I thought). I haven't included Flickr, Trip IT, Friends Re-United and probably a whole host of other services that I use but here is the current map:


I pulled together this map not by merely recalling the services that I use (although I could've done that quite easily with this particular map) but rather by taking a look at my Password Safe datbase and going through the various accounts I have. My Password Safe now has 257 items in it and I know there are some accounts missing!

257 account details. Whatever way you cut it, that's a lot of accounts. Thankfully, I only know the password to a couple of services (and have never known, and probably will never know my Facebook password, for example). I rely almost entirely on Password Safe to access my online accounts.

And here's the issue... So paranoid am I about losing my Password Safe database that I have it copied from my desktop PC to my Mac Mini (on a nightly backup). It is synchronised with my 8gb Freecom USB disk. It is then synchronised with my two laptops (one personal and one work) and it is copied to a secure location on a server I have in a data centre.

So, my precious information is stored in a number of locations. That's a few opportunities for the baddies to try to get it from me. What are the options, though?

Well, of the 257 accounts that I have, hardly any of them support some kind of federated security model. It is true that I can log in to some services using my Google ID or my Yahoo ID, but not many. OpenID? Again, hardly any of my service providers support this. In fact, it seems that I have THREE amazon accounts - one for purchasing; one for Affiliation and one for Amazon Advantage! (I may have an amazon developer account for their API, but can't remember!)

So managing my identity is a fairly manual process just now. Not the case, necessarily, for big corporations who can throw a Sun, Oracle or IBM Identity Management solution at their various data repositories. Could these tools be used "in the cloud" for web users? Would I want to pay for that? Could I host IBM Tivoli Identity Manager on a server on the net, build some connectors to the major websites (such as Facebook, Twitter, Google & Yahoo) for managing accounts? Could I, host a reverse-proxy on this internet-facing server which would provide me with a web-based single-sign on solution to these services?

Technically? Everything is possible. Is it likely? Not a chance... well... not yet. Too many companies are trying to gear themselves towards offering this terrific opportunity to be the master of identity related data but you've got to question why any organisation would want to do it. For your benefit? Not likely.

Maybe I'll build an IdM service just for me :-)

Sunday, February 08, 2009

Socialising

So I have my Facebook account (which I actually like using); a Bebo account (which I never look near); a Twitter account (which I've only just started using in order to find out what the fuss was about); a LinkedIn account (which is useful for my career); a Blogger account (thus this posting); a Plaxo account (in an attempt to synchronise my contact details across my various client machines); a Flickr account (which I rarely use and may be tempted to ditch in favour of Picasa); a Friends Re-United account (which doesn't seem to be a school friend hook-up tool anymore).

What I have created, however, is a social network which is difficult to maintain! I want to be able to find out what my friends are doing and tell them what I am doing. Facebook seems to fit the bill in that regard, though I guess Twitter would probably achieve the same thing.

I'm not into the Facebook applications to be honest. "What's Your Real Age" and "What Lord Of The Rings Character Are You" may seem like fun, but they are fairly trivial and quite franking a waste of time. So I find myself updating my status and writing on friends' walls (though mainly updating my status).

I've managed to get Twitter to update my Facebook status automatically which is great and I've installed a Twitter addon to Firefox which allows me to update my status through the address bar.

All fine and dandy but...

When I signed up to Twitter, I managed to get a "follower" immediately. A pretty young girl from somewhere I've never been to. Why was she interested in me? My first posting said something like "This is my first posting" so it can't be for the intellectual stimulation I provide. Ulterior motives, for sure.

I get friend requests through Bebo from people I've never met. Friend requests from people who were in my year at school (though I never spoke to them then and can't think why they feel the need to speak to me now).

Do social networking sites actually have a negative impact on our sociability? I'm guessing if I write on someone's wall, then I can feel that I've "connected" with them to an extent which removes any obligation to actually go and visit!

I'm also guessing that my "school chums" want to connect with me in order to get their friends number as high as possible? (For the record, I have about 20 friends on Facebook which I think is a lot bearing in mind that I probably only have 2 or 3 friends and they don't even use Facebook!)

The really concerning thing for me, however, is that these applications communicate with each other and share my user details. If one of these applications gets compromised, I maybe in bother! A Google search of my name yields some very disturbing results. Some results are links to pages I have created either on my personal website, this blog or LinkedIn. Some, however, have been created automatically by sites that have skimmed information from my primary sites without my permission. Even though I only have a couple of friends and just a handful of acquaintances on Facebook, it seems that I am a fairly popular guy net-wise.

Herein lies the problem. I want to use these tools to connect with a select few people and while these tools manage to do that, I can't help but worry that too many of my personal details are now public knowledge.

Right... I'm off to tell Twitter that I've blogged some old nonsense in the hope that Twitter will update Facebook with a link to this post!

Monday, January 12, 2009

Joined Up Contacts

So my new Blackberry turned up today and I can't sync my contacts and calendar entries from Thunderbird to that bad boy.

Disappointing... but time for a bit of googling to see how to get around the problem.

And the answer? I'm still disappointed.

I have managed to sort my email accounts in Thunderbird with the help of Folderpanes and I now have access to Hotmail from within Thunderbird using the webmail add-on. I've even sync'd my Google contacts with Plaxo (although that only works one way.... WHY!!!!).

I've downloaded Sunbird (though this gives me no benefit above and beyond the Lightning add-on for Thunderbird).

So... I have all this software, but no way to sync to the Blackberry unless I get radical as such:
  • Use Outlook (which is too expensive)
  • Use Outlook Express (which is too nasty)
  • Use Live Mail (which I just don't like)
  • Buy some additional software
I don't mind paying for software, but I've just spent a load on my Blackberry with the idea that I would be able to sync up simple things like contact lists and calendar entries. To find that I can't do it out of the box is.... disappointing.

Maybe I should write my own routine!

How To Search

So... I have a home network and a Mac Mini which is being used as a Media Server. It will stream video around my home network and I have a Pinnacle Show Center 200 which is a hardware based media player.

However... my Show Center isn't behaving itself. The picture is a bit 'slanty' and the sound is a bit tinny. My understanding is that this is the first sign of a power supply problem! At least, that's according to the horror stories online.

Replacement media players are going to cost anywhere between £100 and £200 and I can't justify that kind of expenditure just now. It would be simpler for me to reuse one of the old laptops with a software based media player installed and stream the output to a television.

What could be simpler?

Well, it is simple - once you have found the necessary software. A bit of googling and job is a good one. Except, googling for "upnp media client software" wasn't that helpful.

The On2Share plugin for WinAMP sounded promising so I downloaded and installed WinAMP. I downloaded and installed the On2Share plugin and the result? It doesn't stream videos at all. In fact, it downloaded the entire video before playing. Rubbish!

Kinsky and 4U2Stream appeared in the search results. I looked at their websites and the terminology used was alien to me. I downloaded them, installed them and.... rubbish! They aren't clients at all - they are remote control clients for UPNP servers.

VideoLAN Network Client also appeared in the search results and after it was downloaded and installed, I found that, once again, the software didn't work.

At this stage, it seemed that too much time and effort had been spent trying to solution what I figured would be an easy problem to solve. Windows Media Center can't play streaming video from a UPNP Media Server; Cyberlink's Media Center wouldn't bother to play streaming video either.

I promised myself just one final attempt and downloaded the XBMC Media Center - the software behind the XBOX Media Center. A quick download, and easy installation and guess what? IT WORKED! It actually worked and it worked brilliantly.

Why oh why was it so difficult to find it? I like to think that I'm skilled in the use of search engines but I'm finding that it is becoming more difficult over time. I recently had a requirement to relocate a DB2 database from one drive to another and my db2relocatedb command was failing. Could I find an answer to my problem? Not a chance.

The problem is that there is just too much information on the web and a tremendous amount of it is just garbage. And this tendency to end up at a site which is merely a site devoted to hosting paid-for banner advertisements is really winding me up.

What am I to do? Maybe the answer lies in storing the decent information when I find it and getting some trusted companions to also store decent information. I'm not talking DIGG here though. I'm not talking blogs. I merely want a repository of information that was difficult to find but was incredibly useful.

Anyone got an answer to that problem?