This door is alarmed

Connect to MS SQL Server using JDBC

The following example shows a java class that can be used to verify if you connection to MS SQL Server using JDBC is working properly. The following code establishes a connection to MS SQL server and then executes a query to print system tables. You need to get Microsoft’s JDBC drivers or jTDS JDBC drivers.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class ConnectMSSQLServer
   public void dbConnect(String db_connect_string,
            String db_userid,
            String db_password)
      try {
         Connection conn = DriverManager.getConnection(db_connect_string,
                  db_userid, db_password);
         Statement statement = conn.createStatement();
         String queryString = "select * from sysobjects where type='u'";
         ResultSet rs = statement.executeQuery(queryString);
         while ( {
      } catch (Exception e) {
   public static void main(String[] args)
      ConnectMSSQLServer connServer = new ConnectMSSQLServer();
      connServer.dbConnect("jdbc:sqlserver://<hostname>", "<user>",

Change <hostname>, <user> and <password> to the correct values. Also, if you use the jTDS drivers, the driver class should be set to net.sourceforge.jtds.jdbc.Driver.

My Friend’s Laptop

One of my friends is using a really messed up Dell Inspiron 8600 right now that should have actually been decommissioned ages ago… Almost the whole of left half of the screen is useless and it needs a support to hold up the screen while in use. Pictures below show what I am talking about:

Removing tags from WordPress posts content

I have been using WordPress since version 1.x and back then there was no native support for tags in WordPress. Easiest thing to add tags to post was to use UTW or other plugins and because of my new found love for tags then, I started using WP-Tagerati and then moved on to Ultimate Tag Warrior. Using these plug-ins meant adding custom tags such as

<tags>foo, bar</tags>



into each post. The plug-ins would parse the post for these custom tags and then tags could be displayed using some APIs provided by the plug-in.

Since v2.3, wordpress now comes with built in support for Tags. This has eliminated the need for using the above mentioned plugins. So, I decided to get rid of them. On disabling the plugins, I noticed that the custom tags along with the tagging information were appearing as post content. To fix this issue, I initially started using Embedded Tag Thing but finally decided to get rid of the tagging information from the posts altogether. Before you do get rid of the tags, do make sure that you import them into wordpress’s tag data, so that you don’t loose this information totally.

Considering that you have a standard installation of WP, fixing this problem is a breeze if you don’t mind playing a bit with phpMyAdmin. Just do the following:

0. Backup WordPress
Backup you WP database. Always, backup your database before going in for direct manipulation of WP data. You can get a whole lot of information by reading about it here.

1. Download Posts table using phpMyAdmin
Go to the phpMyAdmin URL for you WP installation’s database. You can do this by using the very useful WP-phpMyAdmin plugin. As shown in the following screenshot, select the wordpress database that you have configured from the dropdown menu. And then select the wp_posts table. This will refresh the frame on the right side to display the wp_posts table.

Now, we are going to export the posts table. To do this, select the Export tab –> check the Add DROP TABLE checkbox –> hit Go. See the screenshot below.

This will take you to a page that contains a textbox with an SQL script in it. Copy the contents of the textbox and save them in a file.

2. Edit the file
Open the file in your favorite editor. You will see the SQL Dump that contains a lot of queries. Now, run a regex replace query on the content using the regex


This should go though you posts and remove all strings of the type [tags]foobar[/tags]. Change the regex to suit the way you have declared tags in your posts.

3. Import the file contents into wp_posts table
Go to phpMyAdmin and click on the import tab. See the screenshot for reference. Browse to the path where the modified file is located and just hit Go.

This should upload the file contents and execute the SQL queries in the file. If it fails and you see an error complaining about SQL_MODE being set to NO_AUTO_VALUE_ON_ZERO, just add a “” in front of the statement


to comment it out and then try to upload the file again. If things work out fine, you will see a message that says something like “X queries were successfully executed“.

There you go, you are done, If you check the posts contents now, you will not see the tags information. And no need to use any plugins to explicitly manage these tags anymore. Though I do suggest using Simple Tags to gain more control over your tag management.

VMware Player and Ubuntu 8.10 keyboard mapping issues

Yesterday I installed VMware Workstation 6.5 on my fresh install of Ubuntu 8.10. After powering on a Windows XP vm, I realized that I could not use the arrow keys properly. On hitting the left arrow key, start menu was being displayed and other arrow keys had similar issues. Also, using VMware player was completely impossible as ctrl-alt-del wasn’t working.

After searching around a bit I found that many others had faced similar issue. Apparently it is not a bug with VMware Workstation. Due to some updates to Ubuntu 8.10, the keyboard mappings were screwed up. I found good amount of information in the VMware communities forum.

To fix this issue, you simply need to run the following command,

echo 'xkeymap.nokeycodeMap = true' > ~/.vmware/config

and if VMware Player/Server/Workstation was running, just restart it.

You should then be good to go…

Static IP address on Ubuntu 8.10

Last Friday I upgraded my install from Ubuntu 7.04 to 8.10 Intrepid Ibex on my office workstation and I noticed that I was unable to assign static IP to the machine. After reboot the netmask was getting messed up and reset to 22. Look at this bug for more info.

So, I ditched the native ubuntu Network Manager and installed wicd which is another open source network manager that works with Ubuntu. But after configuring wicd with the static IP, I had another problem. Everytime I restarted the machine, I had to manually start the wicd network manager. Instead of trying anything more with wicd, I decided to ditch a network manager altogether and just configure the files myself.

So, to get the network working with static IP, first remove the network manager (Many people have said that it is not necessary, but I prefer to remove it as I wont be using it anyway):

sudo apt-get remove --purge network-manager

Then modify the /etc/resolv.conf with the dns servers and domain names:


Now, modify /etc/network/interfaces and add

auto eth0
iface eth0 inet static

Now, just restart the networking:

sudo /etc/init.d/networking restart

Obviously, you should figure out the netmask, gateway and name servers before you start these steps.

This is all that you need to do to configure the machine with a static IP.

HemingwayEx 1.5 Final

I finally got myself to fix some more bugs and add a couple of new things into the HemingwayEx WordPress theme. I received a few suggestions on features that could be added and after thinking about it a bit, I add some more things to this theme. This will (99.99%) be the last update of this theme coming out on my website. I have been intermittently updating this theme over the last year & a half and now I feel it’s time to move onto something else.

This update includes the following changes:

  • A new CSS with Black, Blue and Gray colors.
  • Added support for Paginating the homepage
  • Added WP Gravatar API into the comments. You can turn it on/off using WP->Settings->Discussion page.
  • Updated the theme to start using js included in WP itself.
  • Removed support for Hemingway blocks. Now, this theme only works with Widgets.
  • Fixed a few bugs reported by Thomas regarding the search page.

To get the theme go on over to the HemingwayEx download page.

It’s been a lot of fun working on this theme and I thank everyone who has used this theme and written to me about it.

VMware player on Ubuntu 8.04 (Hardy Heron)

I recently upgraded my office computer from Gusty to Hardy and VMware player stopped working for me. I looked around a bit and found a nice step-by-step guide to get it up and running. Here are the steps:

  1. cd /usr/lib/vmware/modules/source
  2. cp vmmon.tar vmmon.tar.orig
  3. sudo tar xvf vmmon.tar
  4. cd vmmon-only/include/
  5. sudo vi vcpuset.h
  6. change line 74 from: #include “asm/bitops.h” to: #include “linux/bitops.h”
  7. rm vmmon.tar (return to the folder where you decompressed the tar file)
  8. sudo tar cvf vmmon.tar vmmon-only/
  9. sudo rm -rf vmmon-only/
  10. sudo

To save you some time, I have uploaded the fixed vmmon.tar, that you can use to replace the original with. Just untar the vmplayer package, download vmmon.tar and cp it to <vmplayer_installer_dir>/lib/modules/source/ and then start the installation process.

This same process should work for VMware Server and Workstation as well.

Hemingwayex 1.1 is finally here

I have finally found time now and then in the past three weeks and tweaked HemingwayEx to work with WordPress 2.3+ and WordPress 2.5. I have fixed a lot of small issues here and there with CSS and the PHP code. I also added few more options to make the theme even more customizable. One can now choose to enable/disable sidebars, post navigation, excerpts on homepage, font resizer. Also, I have added in-built support for Related Posts plugin.

I would really like to thank people who have use this theme and have come back to me with bugs and ideas to improve HemingwayEx. Though I didn’t look at the emails/comments for a long time, I did go though all of them while working on this update. I have incorporated many comments and suggestions into this update.

I already have ideas for the next release, but I am sure that is ages away. Work has become so hectic that I have even stopped blogging regularly now. This will be my first post in almost half-a-year.

Anyways, I hope everyone who tries this theme has a good experience.