Wednesday, June 28, 2006

I Write English Real Goodly

Saw this on
... had methamphetamine in his system when his pickup truck drifted off a desert highway and was killed, a coroner's autopsy showed.

The poor pickup truck was killed. A tragedy.

I'd provide a link but I'm sure a corrected version will be posted before too long.

The "new media" often provides news faster but with some unintended (probably) language gaffes.

Thursday, June 22, 2006

SnTT: JDBC in Notes

I just finished with my first use of JDBC in a Notes application to access DB2 and thought I'd share. Initially, I looked at ODBC, but that required setting up a connection in the ODBC Data Sources on the client machine and I really wanted something that would "just work" without having to do anything to the client machines. I had seen a while back some code to automatically create that Data Source but was never able to get it to work in our environment.

First is the Java agent that makes the connection and performs the query in DB2.

import lotus.domino.*;
import java.sql.*;
import java.util.*;
import javax.swing.JOptionPane;

public class DB2Lookup extends AgentBase {

private static String dbuser = "userid";
private static String dbpwd = "pswd";
private static String _url = "jdbc:db2://fully.qualified.server:db2portid/dbname";
private static String _drv = "";
private java.sql.ResultSet rs;
private java.sql.Statement stmt;
private java.sql.Connection con;

public String[] NotesMain(String tableID, String custNum, String custName) {
Vector vec = new Vector();
try {
Properties p = new Properties();
p.put("user", dbuser);
p.put("password", dbpwd);
con = DriverManager.getConnection(_url, p);
stmt = con.createStatement();
tableID + " WHERE CUSTNUM='" + custNum +
"' AND UPPER(NAME) LIKE('%" + custName.toUpperCase() +
while ( {
String sN = rs.getString("NAME");
String sO = rs.getString("OBLIGOR");
vec.add(sN + "" + sO);

} catch (SQLException se) {
// Inform user of any SQL errors
System.out.println("SQL Exception: " + se.getMessage());

} catch (Exception e) {

} finally {
try {
} catch (SQLException se) {
System.out.println("SQL Exception: " + se.getMessage());
if (vec.isEmpty()) {
String forms[] = (String []) vec.toArray( new String[vec.size()]);
return forms;

The agent takes parameters passed to it, executes the DB2 query, processes the result set and creates a string array to return to the caller. The biggest stumbling block I hit was handling queries that returned no records. Until I hit on adding the "NOTHING" entry if the vector came back empty, I kept crashing my Notes client. So beware!

IBM has a JDBC Type 4 driver available for free re-distribution as part of your application. You can find it here (IBM registration required, and this is for DB2 UDB, Cloudscape and Derby. UPDATE: The link points to the version is for Linux/Unix/Windows; not sure if there are drivers for other OSes). The db2jcc.jar and db2jcc_license_cu.jar archives need to be attached to your Java agent (use the Edit Project button to do this).

Here is the LotusScript agent that calls the Java agent.

' Declarations
Option Public
Option Declare
Use "DB2Lookup"
Uselsx "*javacon"

Sub Initialize
Dim docThis As NotesDocument
Dim myClass As JavaClass
Dim myObject As JavaObject
Dim mySession As JavaSession
Dim ws As NotesUIWorkspace
Dim IDs As Variant
Dim stat As Variant

Set ws = New NotesUIWorkspace
Set docThis = ws.CurrentDocument.Document
If docThis.CustName(0) = "" Or docThis.CustNum(0) = "" Or docThis.TableID(0) = "" Then
Messagebox "You must have entries in the Customer Name, Customer Number
and Table fields before using this function"
Exit Sub
End If

Set mySession = New JavaSession()
Set myClass = mySession.GetClass("DB2Lookup")
Set myObject = myClass.CreateObject
IDs = myObject.NotesMain(docThis.TableID(0),docThis.CustNum(0),docThis.Borrower(0))

If IDs(0) = "NOTHING" Then
Messagebox "No customers found meeting your criteria; please revise and try again",
64,"Customer Lookup"
Exit Sub
End If
If Ubound(IDs) > 0 Then
stat= ws.Prompt(PROMPT_OKCANCELLIST,"Select Customer","Select the Customer
from this list:","",IDs)
If stat = "" Then Exit Sub
stat = IDs(0)
End If
With docThis
.CustName = Trim(Strleft(stat,""))
.CustNum = Trim(Strright(stat,""))
End With
Call ws.CurrentDocument.Reload
End Sub

This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at

The agent makes sure there are entries in all the fields passed for the JDBC call. If no records are found, the user is informed. If one record is found, the fields are updated automatically. If more than one record is found, a dialog box is presented from which the user can choose an entry.

Who says Notes/Domino is a closed environment? Now go forth and JDBC!

Categories: Show-n-Tell Thursday_

Thursday, June 1, 2006

No Way!

I saw this from CNN and about fell out of my chair. From the article:
(Ted) Owen, who runs the Global Gaming League (GGL), a media company focused on the lifestyle and culture of gaming, is currently talking with the Chinese government in hopes of bringing competitive video gaming to the 2008 Games as a demonstration sport.

I love watching the Olympics, although a little less since the pros have taken over some of the sports (eg. basketball and hockey). I don't go for things like badminton or table tennis but I can see the people who play them as athletes. But video gaming? Sure, video gaming "does demand incredible hand-eye coordination" as the article says, but "arguably as much as golf and tennis"? In golf, you also have to walk the course and swing a club and tennis players run all over the court.

The only way I could accept this becoming an Olympic event would be if they played virtual reality games where they had to actually move around (as in "run") as part of the game. And it would only be grudging acceptance. Next thing you know, poker "athletes" will want medals for playing Texas Hold 'Em!