Removing Windows Service

October 15, 2009 – 10:12 am

Enough digging in the windows registry. You can easily remove a Windows Service using a command line utility located in the %windir%\system32 called sc.exe


DESCRIPTION:
SC is a command line program used for communicating with the
NT Service Controller and services.
USAGE:
sc [command] [service name] ...
The option has the form "\\ServerName"
Further help on commands can be obtained by typing: "sc [command]"
Commands:
query-----------Queries the status for a service, or
enumerates the status for types of services.
queryex---------Queries the extended status for a service, or
enumerates the status for types of services.
start-----------Starts a service.
pause-----------Sends a PAUSE control request to a service.
interrogate-----Sends an INTERROGATE control request to a service.
continue--------Sends a CONTINUE control request to a service.
stop------------Sends a STOP request to a service.
config----------Changes the configuration of a service (persistant).
description-----Changes the description of a service.
failure---------Changes the actions taken by a service upon failure.
sidtype---------Changes the service SID type of a service.
qc--------------Queries the configuration information for a service.
qdescription----Queries the description for a service.
qfailure--------Queries the actions taken by a service upon failure.
qsidtype--------Queries the service SID type of a service.
delete----------Deletes a service (from the registry).
create----------Creates a service. (adds it to the registry).
control---------Sends a control to a service.
sdshow----------Displays a service's security descriptor.
sdset-----------Sets a service's security descriptor.
showsid---------Displays the service SID string corresponding to an arbitrary name.
GetDisplayName--Gets the DisplayName for a service.
GetKeyName------Gets the ServiceKeyName for a service.
EnumDepend------Enumerates Service Dependencies.
The following commands don't require a service name:
sc
boot------------(ok | bad) Indicates whether the last boot should
be saved as the last-known-good boot configuration
Lock------------Locks the Service Database
QueryLock-------Queries the LockStatus for the SCManager Database
EXAMPLE:
sc start MyService

Debugging SQL Server JDBC Driver

September 16, 2009 – 7:33 am

SQL Server JDBC Driver provides misleading error messages and sometimes even locks down processing SQL Query request.

In one of my application tests that used Hibernate  framework to abstract  database access, SQL Server JDBC Driver went into infinite loop trying to process a simple query on a view such as :

SELECT * FROM PARTITION_TABLE

It filled in seconds my 999999 Eclipse console buffer with junk messages such as:

Sep 15, 2009 5:20:45 PM com.microsoft.sqlserver.jdbc.TDSParser throwUnexpectedTokenException
SEVERE: ConnectionID:3: batch completion: Encountered unexpected unknown token (0x49)
Sep 15, 2009 5:20:45 PM com.microsoft.sqlserver.jdbc.TDSReader throwInvalidTDS
SEVERE: ConnectionID:3 got unexpected value in TDS response at offset:112

It was difficult to debug it. There was not much on the web on. I tried to switch drivers 2.0 to 1.2 different types and still got the same result. I also noticed that people were switching to an open source SQL Server JDBC Driver called – jTDS. The driver supports all SQL Server versions as well as XA or distributed transactions.

I also tried to simplify the query and the way I accessed the query via Hibernate. At the end I decided to try a simple JDBC access that gave me a meaningful error: “VARIANT is NOT SUPPORTED”. I updated my view to cast the problematic column into a NUMERIC and the problem was resolved.

Lesson: frameworks can be helpful and misleading. They filter information and might hide needed information. At the same time SQL Server error message can be interpreted as unexpected response but also as a sign that it was used incorrectly. Putting Hibernate out of the picture helped to identify the issue.

Sep 15, 2009 5:20:45 PM com.microsoft.sqlserver.jdbc.TDSParser throwUnexpectedTokenException

SEVERE: ConnectionID:3: batch completion: Encountered unexpected unknown token (0×49)

Sep 15, 2009 5:20:45 PM com.microsoft.sqlserver.jdbc.TDSReader throwInvalidTDS

SEVERE: ConnectionID:3 got unexpected value in TDS response at offset:112

Database unit testing

September 15, 2009 – 11:13 am

Most of the server side applications use database back-end. Being used to Test-Driven Development practices, it is desirable to be able to write a test for numerous stored procedures we put in our code. Building Java code to launch a simple stored procedure, flush database and setting to a predefined state is a burden. Here are couple tricks I used in my project:

1. Used TSQLUnit for SQL Server – open source, licensed under the LGPL license. There a good tutorial in the SQLServerCentral. You can also use a cookbook for fast introduction.

2. Used  utPLSQL for Oracle testing. You can get up to speed here.

Good luck

Localized Search/POIs

September 9, 2009 – 10:18 pm

Points Of Interest or simply POIs are the feature of tomorrow. GPS and compass enabled smartphones will guide our every step and habits. We will enjoy, go shopping, rest choose place to invest basing on the local suggestion of our little friends. Here are some services that enable this future:

http://www.geocode.ca/

http://foodpages.ca/

Enjoy

Barcode/UPC Scanners apps for smartphones

August 25, 2009 – 2:03 pm

A new waves of apps is on the smartphone app stores and market places. Those are the bar code scanners that allow you to link real world of products with the huge internet database. Instead of trying to use words to provide a vague description of the product, its bar code can be scan. There are multiple sites that provide UPC or any other code databases such as: UPC Database (http://www.upcdatabase.com/).

Android applicaitons:

Here are blackberry applications:

Oracle Partitioning: useful scripts

August 24, 2009 – 10:14 am

Query number of records in each partition of the table:

SET SERVEROUTPUT ON SIZE 100000;
DECLARE
CURSOR c1
IS
SELECT table_name,
partition_name
FROM all_tab_partitions
WHERE table_name = 'MCP_CDR_HIST' order by partition_name asc;

v_sql VARCHAR2(2000);
temp_var NUMBER:=0;
BEGIN
dbms_output.put_line('Start');
FOR rec IN c1
LOOP
EXECUTE immediate 'select count(*) from '||rec.table_name||' partition('||rec.partition_name||')' INTO temp_var;
dbms_output.put_line('The Partition '||rec.partition_name||' of table '||rec.table_name||' has '||temp_var||' rows');
END LOOP;
dbms_output.put_line('END');
END;

Database partitioning: Sliding window solution

August 18, 2009 – 3:53 pm

Sliding window is a classical solution for the most historical databases. A partition is switched in and out. The scenario is supported by majority of database providers.

The following article describes partition switching in or partition exchange for Oracle: http://www.oracle-base.com/articles/misc/PartitioningAnExistingTableUsingExchangePartition.php

Eclipse Galileo (3.5) Clearcase plugin

August 18, 2009 – 1:28 pm

Clearcase plugin for the Galileo Eclipse:

http://www3.software.ibm.com/ibmdl/pub/software/rationalsdp/clearcase/60/update/windows/

This link is actually broken. Installed Open Source plugin (http://eclipse-ccase.sourceforge.net/) and it works fine. Follow these installation instructions(http://eclipse-ccase.sourceforge.net/documents/user_guide.pdf ):

use the update site.
Update site has the following url: http://eclipse-ccase.sourceforge.net/update/
In Eclipse select menu Help → Install New Software…

Use the update site. Update site has the following URL: http://eclipse-ccase.sourceforge.net/update/. In Eclipse select menu Help → Install New Software…

Using Google Bookmarks in Google Chrome

August 17, 2009 – 8:52 pm

I couldn’t find any tool similar to Foxmarks for Google Chrome. However, I encountered this article (http://metaed.blogspot.com/2008/12/using-google-bookmarks-in-google-chrome.html) that suggested adding Google Bookmarks to a list of enabled searche engines in the Google Chrome instance. This basically allows using Google bookmarks.

To add Google Bookmark search to the Chrome address bar, right-click in the address bar, choose Edit search engines…, click Add, fill out the form as follows, and click OK:

Name: Google Bookmarks
Keyword: gb
URL: http://google.com/bookmarks/find?&q=%s

Using it also simple. Type gb in the Chrome’s address bar and press tab. Search engine switches to the Google Bookmarks now.

Java XML Book

August 17, 2009 – 8:12 pm

Here is a nice tutorial on XML and parsing methodes:

http://www.cafeconleche.org/books/xmljava/