magpiebrain

Sam Newman's site, a Consultant at ThoughtWorks

Posts by samnewman

When connecting to a database from Java, it’s very handy to tag your connections. When tracking down performance issues and monitoring at a database levels, being able to seperate out your program’s connections (which could come from a variety of machines). Most database drivers allow you to specify a program name when creating your connection.

With SqlServer, you can specify a program name “on the query string(The MS SQL Server Driver – connection properties)”:http://edocs.bea.com/wls/docs81/jdbc_drivers/mssqlserver.html#1074599 of your JDBC connection. However with Oracle it’s not quite as simple. I spent ages trying to track down how to do this with Oracle, but it seems that where Oracle is concerned useful documentation lies behind expensive consultants or registration screens. Eventually resident database guru (thanks Jason) sent me a snippet of code which does exactly that, and I’m blogging it here for prosperity (and for consumption by the Google spider).

This code opens a connection with the name Test. By querying the database’s @v$session@ dictionary view we can see each connection from our application (by the way, good luck searching
Google using a $ in a search term). @v$session@ exposes a variety of information – including the program name. The final lines of the code prints out the program name of every session currently connected to the database, helping confirm that the snippets code has worked.

class SetProgram
{
  public static void main (String args [])
       throws SQLException
  {
    // Load the Oracle JDBC driver
    DriverManager.registerDriver(new oracle.jdbc.OracleDriver());

    java.util.Properties props = new java.util.Properties();
    props.put("v$session.program", "Test");

    // Connect to the database
    Connection conn =
      DriverManager.getConnection ("jdbc:oracle:thin:user/tiger@localhost:1521:xe",
				   props);

    // Create a Statement
    Statement stmt = conn.createStatement ();

    // Select the PROGRAM field from the V$SESSION table
    ResultSet rset = stmt.executeQuery ("select program from v$session");

    // Iterate through the result
    while (rset.next ())
      System.out.println (rset.getString (1));
  }
}

h3. Specifying program name with C3P0

When configuring this value using the “C3P0(C3P0 – Java database connection pool)”:http://sourceforge.net/projects/c3p0 connection pool, if you want to specify properties like @v$session.program@, you cannot configure login and password using the normal @setPasword@ or @setUser@ methods as it gets its knickers in a twist. Instead you’ll have to place those in the properties object which you pass to the connection pool using the @setProperties@ method on @ComboPooledDataSource@.

This is worth noting, as where @setUser@ and @setPassword@ will be JDBC driver agnostic, the properties bundle passed in isn’t – or more correctly, the properites themselves aren’t.

Amazon web evangalist Jeff Barr will be “giving a talk(Unixdaemon – Jeff Barr in London)”:http://blog.unixdaemon.net/cgi-bin/blosxom.pl/events/aws_jeffreybarr.html on their webservice offerings at Westminster University on the 15th of May. Unfortunately I’ll be unable to attend – I’d of liked to pick Jeff’s brains about “S3”:http://www.amazon.com/gp/browse.html/002-7839271-9683254?node=16427261 off the back of my “recent post(magpiebrain – Is Amazon S3 the first tier 0 Internet service?)”:http://www.magpiebrain.com/blog/2006/03/21/is-amazon-s3-the-first-tier-0-internet-service/ – but I’m sure it will be an interesting event.

If you want to attend make sure you contact organiser Dean Wilson (email: dwilson at unixdaemon.net) so he can let you know of any changes. I’ve added the event to the London 2.0 calendar too.

I suspect this post has a very small audience, although I suspect that goes for the blog as a whole. Anyway, what follows is a step by step instruction for using Outlook 2003 to read your Lotus Notes email.

h3. Assumptions

This has been tested and works for Windows XP, Lotus Notes 6.5.4 (although the MS bridge should work for Release 5 and up), using Outlook 2003.

h3. Download the Microsoft Conntector

It’s “available for free(Microsoft.com – Outlook 2003/2002 Add-in Notes Connector)”:http://www.microsoft.com/downloads/details.aspx?FamilyID=8EBBBA59-5F17-4E52-8980-C4F0DFA92D65&displaylang=en from Microsoft. It states it works for Outlook 2002 and 2003, for use with Notes release 5 or 6.

h3. Uninstall Microsoft hotfixes

It seems that Outlook 2003 security fix “KB892843”:http://www.microsoft.com/Downloads/details.aspx?familyid=1D156043-B041-4305-8442-3C4E3B832788&displaylang=en stops the connector from installing properly. Unless you remove it, you’ll get the error @”Unable to open your default e-mail folders. The server is not available.
Contact your administrator if this condition persists@. This hotfix is also included in some roll-up fixes, so I suggest you remove any and all Outlook related hotfixes. These hotfixes only affect the installation of the connector, so you can re-run Windows Update afterwards.

You can remove hotfixes from the Add/Remove program dialog – just make sure you have the @Show Updates@ checkbox ticked. The Outlook hotfixes will be listed under Microsoft Office.

h3. Install the connector

Shut down both Notes and Outlook. Double click the connector and follow the on screen instructions

h3. Set up Outlook to read your notes email

Start Outlook up. Select @E-Mail Accounts…@ from the @Tools@ menu. Select @Add a new email account@, click @next@, and select @Additional Server Types@ and click @next@ again. Depending on your configuration, you’ll be presented with several server type options. We want @Microsoft Offie Outlook Connector for IBM Lotus Notes Domino@. Click @next@. You’ll now be prompted to exit Outlook before the new account will be active.

Outlook should pick up your notes file automatically.

h3. Re-install the Oulook Hotfixes

As you wouldn’t want to forget that, would you 🙂

Anyway, that should be it. You’ll now have a slightly more usable way of accessing and sending you email, as well as working with calendars and your todo list. Note that you’ll be unable to read all notes email – those sent with high encruption levels (the ones you can’t send to non-notes email accounts and that can’t be forwared) will not show up, but you should get told that they can’t be transfered by the connector.

[java]
Table person = new Table(“person”);
return select(person.star())
.from(person)
.where(person.column(“startDate”).greaterThan(“2005-01-01”)
.and(person.column(“numberOfFriends”).greaterThan(100))
.and(person.column(“age”).greaterThan(21)));
[/java]

[java]
Table person = new Table(“person”);
Column startDate = person.column(“startDate”);
Column numberOfFriends = person.column(“numberOfFriends”);
return select(person.star())
.from(person)
.where(startDate.greaterThan(“2005-01-01”)
.and(numberOfFriends.greaterThan(100)
.or(numberOfFriends.lessThan(50))));
[/java]

[java]
Table person = new Table(“person”);
return select(star())
.from(person)
.where(person.column(“psnId”).notIn(new String[] { “1”, “2” }));
[/java]

From the Squiggle acceptance tests…

When I moved I redirected all the old feeds – apart from my FeedBurner one – on to the new WordPress ones. My sites full post feed is where I get the bulk of my subscribers – the “old URL(magpiebrain – old full post RSS feed)”:http://www.magpiebrain.com/index_full.xml should be permantently redirected to the new “WordPress feed(magpiebrain – the new full post RSS feed)”:http://www.magpiebrain.com/feed/. When I load the old URL in my browser, it correctly redirects and shows the new content. However Bloglines for some reason has yet to display any new content from my new feed. Perhaps Bloglines is ignoring the 301 redirection from my mod_rewrite rule?

I’ll try and chase this up with Bloglines support, but if anyone can shed any light on it I’d appreciate it.

p(update). _update_: According to a “comment”:http://www.intertwingly.net/blog/2004/02/18/Bloglines#c1077175023 over at Sam Ruby’s site that I’m not the only person to have hit this problem. Hopefully Bloglines support will be able to update their database to reflect the new URL’s. It’s a little worrying though that in the year 2006 internet applications like this still aren’t playing nice with standard HTTP return codes

Now that I’ve “moved my sites(magpiebrain – New host, new blog, new screwups)”:http://www.magpiebrain.com/blog/2006/04/17/new-host-new-blog-new-screwups/ over to TextDrive, I need to find a new domain registrar to complete the relocation. My old ISP was an OpenSRS reseller, and I don’t want to keep paying my old monthly fee to them simply to manage my domains.

The two I’ve heard some good things about are “Joker”:http://joker.com and “RegisterFly”:http://www.registerfly.com/, but there are so many out there that a bit more feedback would be nice. It’ll need to handle a few .com’s and at least one .co.uk domain – I definitely need automatic updates and periodic reminder. A reliable web control panel is a must, but I’d rather not pay the earth for managing a few domains.

On a Wednesday instead this week, just for kicks, but once again at the “Olde Bank of England”:http://www.pubs.com/pub_details.cfm?ID=214 from 7pm. No agenda as yet, but I want demos! Leave a comment if you’ll be coming so I can get an idea of numbers.

Though the magic of Google Calendar (I’m so Web 20 it _hurts_) I now have publically available “ical(London 2.0 meet-up events – iCal)”:http://www.google.com/calendar/ical/c7ilcesmkkn0e3bkirk4kgf5cc@group.calendar.google.com/public/basic and “rss(London 2.0 meet-up events – rss)”:http://www.google.com/calendar/feeds/c7ilcesmkkn0e3bkirk4kgf5cc@group.calendar.google.com/public/basic feeds. Once I get home it’ll be on upcoming too (damn corporate firewall tagging it as a dating site…), although unless upcoming starts letting me splice in my Google events soon I’ll probably stop using the service.

p(update). _Update_: I’ve added a simple block on the bottom of this site listing the upcoming London 2.0 events using dwc’s “iCal WordPress plugin”:http://dev.webadmin.ufl.edu/~dwc/2005/03/10/ical-events-plugin/. There is also a specific “category”:http://www.magpiebrain.com/blog/category/web-20/london-20-meet-ups/ and “rss feed”:http://www.magpiebrain.com/blog/category/web-20/london-20-meet-ups//feed for all London 2.0 meet-up information.

Since I signed up to TextDrive I’ve been planning this move. Finally, after several weekends of intense inactivity punctuated with the occasional burst of activity, the blog should be moved. Pretty much all the links should be working, but email me if anything is mis-behaving.

TextDrive

I’ve had no real complaints with my old host, “Gradwell”:http://www.gradwell.com/. Sure, the web control panel needed some interface work, and they weren’t as up to date with new software, but they were solid enough and the support was prompt. The recent TextDrive lifetime hosting offer was enough to tempt me. Given that I was already a “Strongspace”:http://www.strongspace.com/ user the $500 deal ended up paying for itself in a year. Add in great support (both via the forums or via email), up to date software packages and the fact that they donate 50% of their profits to supporting a selection of open source software development and I was sold. Needless to say I’ve not been disappointed since my move.

Wither MovableType – and TextPattern

Yes, after using MovableType for many years I’ve also switched blogging software. My original choice was “TextPattern”:http://www.textpattern.com/ which I use to run another site. I like TextPattern a lot – it’s interface, easy install, ease of customisation. One thing I don’t like is the problematic handling of clean URLs. I needed to remap easily URLs from the old blog to the new using mod_rewrite, and it was very hard with Textpattern. In the end WordPress made the process much simpler. TextPattern does have a steep learning curve – but if the way it decides to handle URLs works for you and like the extreme customisation possible then it might be the one for you.

Enter WordPress

In desperation after many weekends of TextPattern tweaking I tried installing WordPress. As the documentation suggests it really does only take five minutes to install. I’ve bee greatly impressed. The admin interface is clean, there are a wealth of plugins available (and can be easily managed), and the theme handling is very handy for a compulsive tweaker like myself.

Hemingway

The design is a slightly modified “Hemingway” theme. The original really is a very nice piece of work. Over the coming weeks I plan to continue to tweak it, but I’ll be keeping the changes small and incremental – there have been enough changes recently!

p(update). _Update_ I’ve fixed a problem with the montly archive links from the old site not working. Images in articles seem screwed up right now though – but I can’t fix that while behind a corporate firewall Images should now be fixed too.

Thanks to everyone who attended London 2.0 RC 4 last night (in rather cramped conditions). The “usual(Simon Willison’s weblog)”:http://simon.incutio.com/ “suspects”:http://www.brunningonline.net/simon/blog/ were in attendance, as well as Adrian Holovaty who was in for a few days.

“Phil Dawes”:http://www.phildawes.net/blog/ demonstrated both “Bicycle Repair Man(Bicycle Repair Man – Python Refactoring Tool)”:http://bicyclerepair.sourceforge.net/ and the Python testing tool “Protest”:http://www.phildawes.net/blog/2006/03/17/protest-rocks-generate-documentation-from-tests/ (we need screencasts of both!), and I pointed numerous people towards the impressive “DabbleDB”:http://dabbledb.com/utr/ screencast. Demo of the night probably had to be Remi Delon showing off “Python Hosting”:http://www.python-hosting.com/. They offer a very slick, one-click install of a variety of different webapp frameworks (everything from TurboGears to Zope to Django) for a very “reasonable price(Python Hosting shared hosting plans)”:http://www.python-hosting.com/shared_hosting. His screencast is out soon – but put it this way, TextDrive’s TextPanel is going to have a lot to live up to, not to mention their forthcoming Rails-dedicated hosting (note: I’m a TextDrive user myself). Despite their name, Python-Hosting do also provide Rails hosting, however it’s not yet integrated with their slick user interface.

Details on next month’s London 2.0 RC5 coming up soon.