Tuesday, May 20, 2008

Get the queue details from the ActiveMQ

Go to $ACTIVEMQ_HOME/bin
run "./activemq-admin query -QQueue=*"

Showing the sql queries and values for hibernate queries - Log4j configurations

1. Add folowing to hibernate.properties
hibernate.show_sql=true

2. add following to loj4j.xml

<appender name="trace" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="/export/home/log_path/trace.log"/>
<param name="Threshold" value="trace"/>
<param name="DatePattern" value="'.'yyyy-MM-dd-HH'.log'"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{DATE} %-5p [%t] %c{1} - %m%n"/>
</layout>
</appender>

<category name="org.hibernate.type">
<priority value="trace"/>
</category>

<category name="org.hibernate.SQL">
<priority value="trace"/>
</category>


Usefull oracle commands

1) sqlplus login
----------------
sqlplus user_name/password@SID


2) Executing a sql scrip in the sql prompt
------------------------------------------
sql>@insertscriptssql.sql


3)Get the last executed statement from sql promt
------------------------------------------------
Execute last statement = /


4)Set the sql view for more human readable format
--------------------------------------------------
SQL> set linesize 300
SQL> set pagesize 500


5) Selecting indexes
---------------------
select index_name,UNIQUENESS,INDEX_TYPE from user_indexes where table_name='TABLE_NAME';
select index_name, column_name from user_ind_columns where table_name = 'TABLE_NAME';



6) Creating a index
--------------------
CREATE INDEX idx_accountholder_msisdn ON ACCOUNTHOLDER (MSISDN) COMPUTE STATISTICS;
CREATE INDEX IDX_SIMCOUNTER_MSISDN ON DEALER_SIM_COUNTER(MSISDN, ICCID);


7) Selecting the ACTIVE/INACTIVE sessions
------------------------------------------
log as system user-> ROOT access = system/password
SELECT USERNAME, STATUS FROM V$SESSION WHERE USERNAME LIKE '%User_name%';

8) Disabling the constraints
-----------------------------
alter table TABLE_NAME disable constraint CONSTRAINT_NAME;


9) Executing a sql script with a stored procedure
--------------------------------------------------
1. Edit the sql scrip with following at the end (carefull about the space line above the .(dot))

------------------

.

RUN;
-------------------
2. Execute with sql>@scrip_name.sql
3. Check the creation sql>desc STORED_PROCEDURE_NAME;


10) Get the Oracle version
--------------------------
select * from v$version where banner like '%Oracle%';

Usefull shell commands

1) Unzippin tar.gz
------------------
gzip -cd name_of_the-file.tar.gz | tar xfv -


2)Farwading to dev/null log when start up
----------------------------------------
./start_app.sh &> /dev/null &


3) Redirecting a log to dev/null
-------------------------------
ln -s /dev/null event.log


4) Splitting a file into parts
------------------------------
split -b1024*1024*50 event.log


5)Create multiple directories
-----------------------------
mkdir -p test_data/sap/in


6) Zipping a file
------------------
zip -r zip_file_name.zip dir_name/


7) Get the system usage
------------------------
Create a shaell scrip and add folowing:
uptime >> system_load.log
vmstat >> system_load.log
sar -u 10 1 >> system_load.log


8) Get the heap size in64 bit machine
--------------------------------------
Get the applicatin process id >ps -ef| grep java (say its 19543)
jmap -heap -d64 19543


9) Get the machine IP in Solaris
---------------------------------
/sbin/ifconfig -a


10) Get the capasity of the current directory
----------------------------------------------
du -sh


11) Extract and compress jar files
----------------------------------
1. jar -xvf abc.jar ->extract
2. go to the directory with all the directories, jar -cvf abc.jar * ->compress


12) Extracting a war file
-------------------------
jar -xvf customercare.war