Monday, March 8, 2010

Pitfalls of stopping a running script in Oracle SQL Developer


When Oracle SQL Developer is executing a long running script it usually displays a progress bar with a 'cancel' button like the one on the right displayed next to it.

Recently, I erroneously launched a script and hurried to press the said button. Sure enough, the progress bar disappeared and the cancel button was greyed out. Still, I went ahead and pressed the roll back transaction several times.

It was a great shock to me that the 'cancelled' transaction was never stopped, and the data had been posted to the database. The roll back has obviously not worked as well, possibly because SQL Developer considered the script as 'cancelled'.

My two cents on this is that if a transaction that does not commit automatically is started erroneously, let it complete successfully, then roll it back.

Thursday, February 25, 2010

Enabling clustered tomcat mcast port in OpenSUSE firewall

The default firewall configuration will drop the multicast packets needed for tomcat instances in a cluster to 'ping' each other.

Open the firewall application as root, and select Broadcast on the navigation panel on the left.



Click the add button, select the active firewall zone and select 'User Defined' under service. Finally specify the protocol as UDP and provide the port number in use.



Click add then save the settings which take effect immediately.

Monday, February 15, 2010

Reading Standard Input in Ruby Scripts

I recently spent a few agonizing hours struggling to get a ruby script to work.
The script was iterating over standard input and subjecting the input line to a file/dir test. Valid files were not being recognized.

I later realized that the cause of the problem was the newline that is included in the input received from standard input. After stripping away the newline, the script worked.

Copying a Pentaho Report Repository Manually

Copying a existing report repository is an easy way to create another repository for use with a test or development database. It can also be a way to create a production repository from an erstwhile development version.

These are the steps I used on Linux:
  1. Copy the repository

    cp -r repo-prod repo-dev

  2. Edit the index.properties file in repo-dev and change the name property to give it a different name than the original.

  3. Change the data source name to match the development one in each xaction file
    find . -name '*.xaction' | xargs sed -i 's/data-prod/data-dev/g'

  4. Change the repository name in xaction files that have sub-actions
    find . -name '*.xaction' | xargs sed -i 's/repo-prod/repo-dev/g'

  5. Change the image paths in the report design .xml files. cd into the directory first
    find . -name '*.xml' |xargs sed -i 's|/old/prefix/|/new/prefix/|'


Monday, January 18, 2010

Invalid column type in Pentaho

A java.sql.SQLException: Invalid column type error in pentaho had broken a previously functioning report upon the introduction of changes.

On close inspection, I traced the problem to a newly introduced a parameter in an SQL statement. The parameter was supplying data for use in a SQL IN(...) clause. When a variable of type string-list was supplied, the report worked. The exception above was thrown when a variable of type string was supplied.

To resolve the problem, I created a Java ArrayList to hold the single value and hence ensure that the variable supplied was always a list.

Monday, December 14, 2009

Setup subversion modules for apache2 on OpenSUSE 11.1

I had installed apache2 earlier using the zypper command and it was running ok. To install subversion, I ran:
# zypper install subversion-server

That install went smoothly. From my previous experience setting up apache2 for clustering tomcat, I knew that enabling and disabling modules was to be accomplished through the a2enmod and a2dismod commands respectively. This is an excellent alternative to hand editing the configuration files.

After some trial and error, the commands listed below are what was needed to get the modules setup correctly. The order of commands is important as the modules need to be loaded in the order of dependency.

# a2enmod dav
# a2enmod dav_svn
# a2enmod authz_svn


Additionally, the following links helped me complete the process of setting up the server:
Apache Howto SSL - opensuse.org
Setting up a Subversion server using Apache2 - opensuse.org
Configuring Apache for Subversion use- techrepublic.com

Tuesday, December 1, 2009

Regex Repetition Matching

I use regex on and off. A situation arose where I needed to use repetition matching, something I knew existed but had never used before.

I needed to match a string with at most 36 characters. Using the regex below worked but it also matched strings with commas inside them
.{,36}
I specified that I did not wish to have commas in the string, resulting in this next expression.
[^,].{,36}
After this change, the expression stopped matching the target strings e.g. 9F7096D0D20949ACB2DA1EE57488F015
or
99AD7ECC-222A-AC8A-4BF8-F04B159DDBFB
It instead matched a string like
9200','LI','NA',null,'Y','L','N','N',

Realizing that the attempt to leave out the commas had caused the trouble, I adjusted the expression, which matched the desired strings.
[^,]{,36}