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 {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection(db_connect_string,
db_userid, db_password);
System.out.println("connected");
Statement statement = conn.createStatement();
String queryString = "select * from sysobjects where type='u'";
ResultSet rs = statement.executeQuery(queryString);
while (rs.next()) {
System.out.println(rs.getString(1));
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args)
{
ConnectMSSQLServer connServer = new ConnectMSSQLServer();
connServer.dbConnect("jdbc:sqlserver://<hostname>", "<user>",
"<password>");
}
}
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.
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>
or
[tags]foobar[/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
\[tags\].+?\[/tags\]
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
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
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.
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…
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:
search foo.bar.com bar.com
nameserver 192.168.0.1
nameserver 192.168.0.2
Now, modify /etc/network/interfaces and add
auto eth0
iface eth0 inet static
address 192.168.0.10
netmask 255.255.252.0
gateway 192.168.0.253
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.
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.
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:
- cd /usr/lib/vmware/modules/source
- cp vmmon.tar vmmon.tar.orig
- sudo tar xvf vmmon.tar
- cd vmmon-only/include/
- sudo vi vcpuset.h
- change line 74 from: #include “asm/bitops.h” to: #include “linux/bitops.h”
- rm vmmon.tar (return to the folder where you decompressed the tar file)
- sudo tar cvf vmmon.tar vmmon-only/
- sudo rm -rf vmmon-only/
- sudo vmware-config.pl
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.










Recent Comments