Wednesday, March 26, 2008

Starting Oracle database

In order to start Oracle instances hosted in Linux environments. There are 2 things need to be done.
1. Start the database instance
Use sqlplus to login without connecting to any database:
$ ./sqlplus /NOLOG
SQL > connect webm/webm
SQL > startup

2. Start up the database listener
$ ./lsnrctl start

Check the listener status
$./lsnrctl status

Input/Output Redirection and nohup

This article is from Input/Output redirection made simple in Linux .
Linux follows the philosophy that every thing is a file. For example, a keyboard, monitor, mouse, printer .... you name it and it is classified as a file in Linux. Each of these pieces of hardware have got unique file descriptors associated with it. Now this nomenclature has got its own advantages. The main one being you can use all the common command line tools you have in Linux to send, receive or manipulate data with these devices.
For example, my mouse has the file descriptor '/dev/input/mice' associated with it (yours may be different).
So if I want to see the output of the mouse on my screen, I just enter the command :
$ cat /dev/input/mice

... and then move the mouse to get characters on the terminal. Try it out yourselves.
Note: In some cases, running the above command will scramble your terminal display. In such an outcome, you can type the command :
$ reset
... to get it corrected.

Linux provides each program that is run on it access to three important files. They are standard input, standard output and standard error. And each of these special files (standard input, output and error) have got the file descriptors 0, 1 and 2 respectively. In the previous example, the utility 'cat' uses standard output which by default is the screen or the console to display the output.
  • Standard Input - 0
  • Standard Output - 1
  • Standard Error - 2
Redirecting output to other files

You can easily redirect input / output to any file other than the default one. This is achieved in Linux using input and output redirection symbols. These symbols are as follows:
> - Output redirection
< - Input redirection
Using a combination of these symbols and the standard file descriptors you can achieve complex redirection tasks quite easily.

Output Redirection
Suppose, I want to redirect the output of 'ls' to a text file instead of the console. This I achieve using the output redirection symbol as follows:
$ ls -l myfile.txt > test.txt
When you execute the above command, the output is redirected to a file by name test.txt. If the file 'test.txt' does not exist, then it is automatically created and the output of the command 'ls -l' is written to it. This is assuming that there is a file called myfile.txt existing in my current directory.

Now lets see what happens when we execute the same command after deleting the file myfile.txt.
$ rm myfile.txt
$ ls -l myfile.txt > test.txt
ls: myfile.txt: No such file or directory -- ERROR
What happens is that 'ls' does not find the file named myfile.txt
and displays an error on the console or terminal. Now here is the fun
part. You can also redirect the error generated above to another file
instead of displaying on the console by using a combination of error
file descriptor and output file redirection symbol as follows:
$ ls -l myfile.txt 2> test.txt
The thing to note in the above command is '2>' which can be read as - redirect the error (2) to the file test.txt.
When working with the UNIX operating system, there will be times when you will want to run commands that are immune to log outs or unplanned login session terminations. This is especially true for UNIX system administrators. The UNIX command for handling this job is the nohup (no hangup) command.

Normally when you log out, or your session terminates unexpectedly, the system will kill all processes you have started. Starting a command with nohup counters this by arranging for all stopped, running, and background jobs to ignore the SIGHUP signal.

The syntax for nohup is:

nohup command [arguments]
You may optionally add an ampersand to the end of the command line to run the job in the background:

nohup command [arguments] &

If you do not redirect output from a process kicked off with nohup, both standard output (stdout) and standard error (stderr) are sent to a file named nohup.out. This file will be created in $HOME (your home directory) if it cannot be created in the working directory. Real-time monitoring of what is being written to nohup.out can be accomplished with the "tail -f nohup.out" command.

Although the nohup command is extremely valuable to UNIX system administrators, it is also a must-know tool for others who run lengthy or critical processes on UNIX systems.

Thursday, March 20, 2008

view trigger in MS SQL

Try the following statements in Query Analyzer:
use ;
sp_helptext ;
This is used to see the trigger content.
select * from sysobjects where name=;
This is used to see the trigger properties.

Here's a list of trigger status code:
- a value of 1610615808 when an INSERT trigger is disabled
- a value of 1610615040 when a DELETE trigger is disabled
- a value of 1610615296 when an UPDATE trigger is disabled.

If you want to get the trigger name related to a table, you can use entreprise manager to check dependencies for that table.

In order to check if a trigger is disabled, you can use the following statement:
select name, objectproperty(id, 'ExecIsTriggerDisabled') as Disabled from sysobjects where xtype='tr';

In order to enable a trigger, use the following statement:
alter table enable trigger ;
or enable all triggers:
alter table enable trigger all;

Friday, March 07, 2008

Communicate with webSphere MQ using simple Java client

There are pieces of sample code available in the internet about how to communicate with MQ server using Java. However, you'll find out if you use MQ API, it will not work, always complaining about ClassDefNotFound, even after you include com.ibm.mq.jar and connector.jar in your classpath !!!
In order to resolve such a problem, you need to include com.ibm.mq.jar in the JVM bootstrap entries. It can be easily done using Eclipse!
To get more information about Java class loading mechanism. Here are a couple of interesting entries:
Internals of Java Class Loading
Understanding the Java Classloading Mechanism