Unlock BSNL 3G Teracom data card use it with Airtel and Vodafone Model no : LW272

How to Unlock BSNL 3G data card to use it with Airtel and Vodafone Model no : LW272 ?
How to unlock BSNL 3G data card( Model no : LW272 )use it with Airtel and Vodafone TATA DOCOMO etc.

I have purchased my BSNL 3G device ( Model no : LW272 ) in the start of year 2009, during this time no other providers were not available in the 3G market.
But time changes and slowly players like Docomo, Airtel and Vodafone etc guys entering market. So I was curious to know/try whether the same BSNL USB Data card can help me if I would like to shift to new operator in future. Luckly my device is not Hardware locked but it is just software locked. If it is hardware locked also we need to flash the memory.
In this BSBL 3G teracome device model no LW272 it is just interface software locked. Thats why it shows " Unauthorised sim, your modem will get closed now" .

So I tried the below steps and worked fine for me with vodafone 2G using Vodafone Mobile connect plan.(Post paid 350/month unlimited).

1. Install BSNL 3G software initially comes with the device to support the modem by installing the drivers.
2. Then check if you have still BSNL 3G sim working whether is connecting or not.
3. Once it is working as expected , go to the install location of BSNL 3G device software Ex : C:\Program Files\BSNL 3G Data Card\BSNL 3G and rename the BSNL 3G.exe to some thing else.
To prevent it running from the start of device.
4. Now create one new dial up connection by selecting the device HSPA DataCardPropritary USB MODEM
5. while creating dialup connection use dialing number *99#  ;  user name and password will be blank. (depending on the signal provider dialing number might change; but for Vodafone *99# is working)
6. Now disconnect the device and remove BSNL sim and keep the other sim card ex : Vodafone.
7. Just wait for 30 sec till the 3G usb LED glows to Green. Unless it glows green you cant do any thing.
8. Now just click connect for the dialup you created already.
9. Now you are all set to use the BSNL device for other operators also.
10. enjoy your Internet now !

Hopefully same steps hold good for Vodafone 3G also which is coming soon !

Referecne : [1] [2]
Special Thanks to
http://www.dreamit.co.in/

Read more


Redirecting SQL select query output to HTML file - shell script, spool

This post main aim is to redirect the SQL select query output to a file for example to make a simple HTML file to display the select query output.
In this example I created two sample files one is 1.sh and another one is select.sh
File 1:
bash-3.00# cat 1.sh
sqlplus PV_ADMIN/PV@PV<< EOF
@select.sql
exit
EOF


File 2 :
bash-3.00# cat select.sql
set linesize 200
set pages 1000
set feedback off
set markup html on spool on
spool test.html
select * from PV_REPORT.AGINFO;
spool off;
so when I run the 1.sh it simply calls select.sh to spool the output to a test.html which will contain the select of the required SQL query.


Another simple file 
bash-3.00# cat selctftp.sh
#!/bin/sh
#
# This script will make connection to Proviso DB
# and selects the data required from a particular
# table to populate it in a file and uploads to
# your target server
#
#
NOW=`(date +"%b-%d-%y")`
echo $NOW
echo "$0 Running on $NOW"
LOGFILE="log-$NOW.log"
echo $LOGFILE
su - oracle  <

id
sqlplus PV_ADMIN/PV@PV
set wrap off
spool $LOGFILE
select * from PV_REPORT.AGINFO;
sppol off
quit

kk

Read more


Indian government services online

Kindly save it...... All government office related links are available....
This section provides you with information and useful links to avail various Citizen Services being provided by the Central & State/UT Governments in India. The list, however, is not exhaustive, as they are committed to adding more and more information about other services for which citizens and other stakeholders need to interact with the Government. Hope this is helpful for you...



Obtain:

*   Birth Certificate <http://www.india.gov.in/howdo/howdoi.php?service=1>
*   Caste Certificate <http://www.india.gov.in/howdo/howdoi.php?service=4>
*   Tribe Certificate <http://www.india.gov.in/howdo/otherservice_details.php?service=8>
*   Domicile Certificate <http://www.india.gov.in/howdo/howdoi.php?service=5>
*   Driving Licence <http://www.india.gov.in/howdo/howdoi.php?service=6>
*   Marriage Certificate <http://www.india.gov.in/howdo/howdoi.php?service=3>
*   Death Certificate <http://www.india.gov.in/howdo/howdoi.php?service=2>
*   Search More - How do I <http://www.india.gov.in/howdo/advancedsearch.php>


Apply for:


*   PAN Card <http://www.india.gov.in/howdo/otherservice_details.php?service=15>
*   TAN Card <http://www.india.gov.in/howdo/otherservice_details.php?service=3>
*   Ration Card <http://www.india.gov.in/howdo/howdoi.php?service=7>
*   Passport <http://www.india.gov.in/howdo/otherservice_details.php?service=2>
*   Inclusion of name in the Electoral Rolls <http://www.india.gov.in/howdo/howdoi.php?service=10>
*   Search More - How do I <http://www.india.gov.in/howdo/advancedsearch.php>


Register:


*   Land/Property <http://www.india.gov.in/howdo/howdoi.php?service=9>
*   Vehicle <http://www.india.gov.in/howdo/howdoi.php?service=13>
*   With State Employment Exchange <http://www.india.gov.in/howdo/howdoi.php?service=12>
*   As Employer <http://www.india.gov.in/howdo/otherservice_details.php?service=17>
*   Company <http://www.india.gov.in/howdo/otherservice_details.php?service=19>
*   .IN Domain <http://www.india.gov.in/howdo/otherservice_details.php?service=18>
*   GOV.IN Domain <http://www.india.gov.in/howdo/otherservice_details.php?service=25>
*   Search More - How do I <http://www.india.gov.in/howdo/advancedsearch.php>


Check/Track:


*   Waiting list status for Central Government Housing <http://www.india.gov.in/howdo/otherservice_details.php?service=9>

*   Status of Stolen Vehicles <http://www.india.gov.in/howdo/otherservice_details.php?service=1>
*   Land Records <http://www.india.gov.in/landrecords/index.php>
*   Causelist of Indian Courts <http://www.india.gov.in/howdo/otherservice_details.php?service=7>
*   Court Judgements (JUDIS ) <http://www.india.gov.in/howdo/otherservice_details.php?service=24>
*   Daily Court Orders/Case Status <http://www.india.gov.in/howdo/otherservice_details.php?service=21>
*   Acts of Indian Parliament <http://www.india.gov.in/howdo/otherservice_details.php?service=13>
*   Exam Results <http://www.india.gov.in/howdo/otherservice_details.php?service=16>
*   Speed Post Status <http://www.india.gov.in/howdo/otherservice_details.php?service=10>
*   Agricultural Market Prices Online <http://www.india.gov.in/howdo/otherservice_details.php?service=6>
*   Search More - How do I <http://www.india.gov.in/howdo/advancedsearch.php>


Book/File/Lodge:


*   Train Tickets Online <http://www.india.gov.in/howdo/otherservice_details.php?service=5>
*   Air Tickets Online <http://www.india.gov.in/howdo/otherservice_details.php?service=4>
*   Income Tax Returns <http://www.india.gov.in/howdo/otherservice_details.php?service=12>
*   Complaint with Central Vigilance Commission (CVC) <http://www.india.gov.in/howdo/otherservice_details.php?service=14>

*   Search More - How do I <http://www.india.gov.in/howdo/advancedsearch.php>

Contribute to:


*   Prime Minister's Relief Fund <http://www.india.gov.in/howdo/otherservice_details.php?service=11>
*   Search More - How do I <http://www.india.gov.in/howdo/advancedsearch.php>

Others:


*   Send Letters Electronically <http://www.india.gov.in/howdo/otherservice_details.php?service=20>
*   Search More - How do I <http://www.india.gov.in/howdo/advancedsearch.php>  

Recently Added Online Services:


*   Tamil Nadu: Online application of marriage certificate for persons having registered their marriages <http://www.india.gov.in/howdo/onlineservice_detail.php?service=2691>
*   Tamil Nadu: Online District wise soil Details of Tamil Nadu <http://www.india.gov.in/howdo/onlineservice_detail.php?service=2693>
*   Tamil Nadu: View Water shed Atlas of Tamil Nadu <http://www.india.gov.in/howdo/onlineservice_detail.php?service=2694>
*   Tamil Nadu: E-Pension District Treasury Tirunelveli <http://www.india.gov.in/howdo/onlineservice_detail.php?service=2695>

*   Meghalaya: Search Electoral Roll Online by Name (2008) <http://www.india.gov.in/howdo/onlineservice_detail.php?service=2697>
*   Meghalaya: Search Electoral Roll Online by EPIC number (2008) <http://www.india.gov.in/howdo/onlineservice_detail.php?service=2698>
*   Meghalaya: Search Electoral Roll Online by House number (2008) <http://www.india.gov.in/howdo/onlineservice_detail.php?service=2699>
*   Meghalaya: Search Electoral Roll Online by Part number (2008) <http://www.india.gov.in/howdo/onlineservice_detail.php?service=2700>

*   Himachal Pradesh: Revised Pay and Arrears Calculator-Fifth Pay <http://www.india.gov.in/howdo/onlineservice_detail.php?service=2702>

*   Andhra Pradesh: Online Motor Driving School Information <http://www.india.gov.in/howdo/onlineservice_detail.php?service=2705>

Global Navigation:


*   Citizens <http://www.india.gov.in/citizen.php>
*   Business (External website that opens in a new window) <http://business.gov.in/>
*   Overseas <http://www.india.gov.in/overseas.php>
*   Government <http://www.india.gov.in/govt.php>
*   Know India <http://www.india.gov.in/knowindia.php>
*   Sectors <http://www.india.gov.in/sector.php>
*   Directories <http://www.india.gov.in/directories.php>
*   Documents <http://www.india.gov.in/documents.php>
*   Forms <http://www.india.gov.in/forms/forms.php>
*   Acts <http://www.india.gov.in/govt/acts.php>
*   Rules <http://www.india.gov.in/govt/rules.php>
*   Schemes <http://www.india.gov.in/govt/schemes.php>
*   Tenders <http://www.india.gov.in/tenders.php>
*   Home <http://www.india.gov.in/default.php>
*   About the Portal <http://www.india.gov.in/abouttheportal.php>
*   Site Map <http://www.india.gov.in/sitemap.php>
*   Link to Us <http://www.india.gov.in/linktous.php>
*   Suggest to a Friend <http://www.india.gov.in/suggest/suggest.php>
*   Help <http://www.india.gov.in/help.php>
*   Terms of Use <http://www.india.gov.in/termscondtions.php>
*   Feedback <http://www.india.gov.in/feedback.php>
*   Contact Us <http://www.india.gov.in/contactus.php>
*   Accessibility Statement <http://www.india.gov.in/accessibilitystatement.php>

Read more


shell script to upload/ftp files to remote machine automatically

Shell script to upload files using FTP from one machine to remote machine automatically

The below simple shell script will automate the FTP steps, to upload file(s) from one machine to other easily ...
edit it according to ur convinece ..

nc184120:/opt/builds # cat ftp.sh
#!/bin/bash

HOST='9.142.193.94'
USER='root'
PASSWD='havefun'

ftp -i -n $HOST <<kris
user ${USER} ${PASSWD}

binary
cd /opt
put cds_db2_admin.sql
quit
kris

nc184120:/opt/builds # ./ftp.sh
Connected to virgo.in.ibm.com.
220-FTP Server (user 'krishna.g@in.ibm.com')
220
331-Password:
331
230-230 User root logged in.
230
Remote system type is UNIX.
Using binary mode to transfer files.
200 Type set to I.
250 CWD command successful.
local: cds_db2_admin.sql remote: cds_db2_admin.sql
229 Entering Extended Passive Mode (|||64693|)
150 Opening BINARY mode data connection for cds_db2_admin.sql.
100% |**************************************************************************************************************************************|  1101       6.73 MB/s    00:00 ETA
226 Transfer complete.
1101 bytes sent in 00:00 (4.48 KB/s)
221-You have transferred 1101 bytes in 1 files.
221-Total traffic for this session was 1601 bytes in 1 transfers.
221-Thank you for using the FTP service on virgo.
221 Goodbye.



Read more


Rational purify coverage for J2EE application deployed in Websphere

Code coverage for J2EE applications deployed in Websphere using Rational Purify plus

Rational's purify plus is one of the best code coverage tool I have seen till today, It has multiple capabilities in which I got a chance to work with is code coverage capability. Some times it is required for Developers and testers to know what part of the code is not getting executed, which part is getting executed during specific scenario of usage etc. In this case it is always good to use a code coverage too like purify plus to monitor our application while running and analyze the results of code run.  The general process of code coverage is simple for any normal java applications, but when comes to a J2EE applications deployed and running under Websphere application server as a service needs more settings and configurations. In the web we can find many documents for configuring simple Java applications and other for code coverage.

So this post main aim is to explain the steps to configure the code coverage for J2EE application deployed under websphere and running as a system service.

Environment description : 
 Operating system : Windows XP / 2003
 Webserver / Applicaiton server : Websphere
 Application : J2EE type
Running as : Windows service.

Collect data by changing the WAS configuration file
When the Java process for hosting WAS is initialized, it gets its command line options from the server configuration file. This file exists for every WAS node and every WAS server. The location and name of this file is defined as follows:
<WAS root>\profiles\<your active profile>\config\cells\< cell id>\nodes\<node id>\servers\<server name>\server.xml

For example, if WAS is installed in C:\WAS, the profile name is ‘MyProfile’, the cell id is ‘MyCellId’, the node id is ‘MyNodeId’, and the server name is ‘MyServer’. The configuration file path will be defined like this:

C:\WAS\profiles\MyProfile\config\cells\MyCellId\nodes\MyNodeId\servers\MyServer\server.xml

Ex :
C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01\config\cells\ibm-b51282f6ec3Node01Cell\nodes\ibm-b51282f6ec3Node01\servers\CDSServer

For example:
<jvmEntries xmi:id="JavaVirtualMachine_1284026476671" verboseModeClass="false" verboseModeGarbageCollection="false" verboseModeJNI="false" runHProf="false" debugMode="false" debugArgs="-Djava.compiler=NONE -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7777" genericJvmArguments="-DPD_DT_ENABLED=true -XrunPureJVMPI:Coverage" executableJarFileName="-Xbootclasspath/a:%PPLUS_HOME%\Rational.jar" disableJIT="false">

The best way to change the profile is to use the WAS administrative console. However, if you do not have access to the console or do not have sufficient rights to edit the server configuration, you may edit the XML file directly. You should locate the jvmEntries element in this file and change the appropriate VM options by adding the JVMPI loading option: -XrunPureJVMPI:

After saving the file or applying these changes from the administrative console you should restart the server process. After the new instance of WAS starts, it will run with the appropriate profiler attached.

So to do the code coverage for any J2EE applications deployed under web sphere and WAS server is running as a system service. So if we edit prefilters in the default settings, this is not going to have any effect on the running service. This is because PureCoverage is saving the default settings in the folder named "c:\documents and settings\\application     data\rational\purecoverage\coverage.ini"                               
Whereas WAS running as a service is using the configuration file named "c:\documents and settings\localservice\application                    
data\rational\purecoverage\coverage.ini"                               
In other words, the service profile doesn't correspond to the          
PureCoverage profile, therefore they are trying to access different    
default INI files.                                                     

There are several ways to work around this problem:                    
1. Edit prefilters in the application settings, not the default        
settings.                                                              
2. Copy the coverage.ini file from your profile to the service profile 
(see above)                                                            
3. Run WAS as a user process, not as a system service.(User should be same the user with which purify was run)                  
4. Change the user associated with the service to be the same as the one
running the coverage.                                                  
5. Manually edit the coverage.ini file in the local service profile. 

so the best I followed after changing the server.xml file is 3rd one , run you websphere service as the user with which purify coverage was run ... 
Go to Windows 
Start > Run > services.msc > Locate your service ex  : 
IBM WebSphere Application Server V6.1 - CDSServer
> Right click on it > Properties > go to Log on Tab > Select This Account > Provide the user and passwords which is same as the user which is running Purify coverage. > Apply > Ok. 
  • Now launch the Purify coverage once. 
  • Empty coverage window opens up ... 
  • Then now re-strat the Websphere service. 
Now coverage should automatically pick up the chnages and pick the classed which you want to instrument.

How to apply filters in Purify plus / coverage : 
License issues in the Purify plus :

Read more


Vinayaka chavithi and Ramzan / Ramadan Wishes



Today is really a special day I felt ..as the country like India which follows "Unity in diversity" with perfect mix of Hindus and Muslims celebrating the same day as "Ganesh Chaturthi" and "Ramzan" festivals.

I wish you all Indians happy Ramzan and Ganesh chaturthi...
Here are few useful things for this special day ...
Vinayaka Chavithi Vratha Kalpam PDF and MP3 Downloads
Download
Vinayaka Chavithi Vratha Kalpam(PDF Format)
Source2:
Vinayaka Chavithi Vratha Kalpam(PDF Format)
Vinayaka Chavithi Vratha Kalpam - part1(MP3 Format)
Vinayaka Chavithi Vratha Kalpam - part2(MP3 Format)
Kanipakam Ganesh Special Coverage

వినాయక చవితి శుభాకాంక్షలు

More downloads from Eeenadu site click this ... 

Read more


ETV D5 JODI

ETV D5 - JODI

Yes you herd it right !! ETV D5 * JODI is ready and launched ...It is on air already..
Missed to see launch episodes of it ..here are they for you ..Enjoy. BTW in this episode you can see D4 Winners announcement too ... 
UdayaBhanu is still continued to be the anchor for the show but this time JODI special judges are different , Rekha and Prakash. 
D1 - Prabhu Deva
D2 - Jr. NTR
D3 - Allu Arjun
D4 - Shreya 
Finals were pranced by most famous celebrities of the Telugu industry till today ...let's see who is going to be the brand ambassador for this D5 - JODI special.
Some of the masters involved in this show are .. 
Dhee Finals : 
Sekhar master and poppy master reached finals. 
And Sekhar won the finals. 
D5 Brand ambassador was Young Rebel star " Prabhas ".
All show parts aired on 
Episode 1 - Sept 1 : Link






Read more


Shravanabelagola-Beluru-Halebidu-Bangalore

One day Trip to Shravanabelagola - Beluru - Halebidu from Bangalore

After so much longings about a trip; my gang and me decided to travel to Hasan district of Karnataka which is famous for its best architecture created by Hoyasala Dine sty.Our first reach out is Shravanabelagola from Koramangala (Bangalore), we were five started at 5 AM in the morning by Qualis on the way at Hennur picked up another friend so total we were six. 

The way route we have choosen was
Bangalore --> Nelamangala --> Kunigal --> Hirisave --> Shravanabelagola --> Halibedu --> Beluru
Start from Bangalore take Tumkur Road NH 4 towards Yeshwantpur 30 km on NH-4 reach Nelamangala and Travel 44 KM to hit NH-48 and take left at Neelamangala
Reach Kunigal and from there 52 km continue on NH 48 to reach Hirisave continue 16 km and Turn Left from Hirisave that connects to Shravanabelagola, from here every thing is easy to reach Halibedu and Beluru.
We traveled around 580 KM in this whole trip.


Shravanabelagola - Wiki
Finally we reached top of the hill where we can see huge (57 Feet)Bahu bali / Gomateswara idol. As it was one of the best pilgrimage center for Jains; we found so many Jain's and foreign tourists as well. I was surprised to see the tourists actively climbing the hill with out any fagged feeling. Got to know that this huge idol was build by king "Chamundaraya".
Gomateswara monolithic idol

The word Shravanbelagola means "The white pond of the Shravana" -as the name suggest there is nice pond we can see from the top of the hill, nice scenic view from the top of the hill. Just beside this hill we can see another hill called Chandragiri(Chikka betta) which has many memorials to other Jain monks. It is believed that emperor "Chadragupta Mourya" meditated on this hill. By the way there were Palanquin facilities from the down of the hill to reach up of the hill, around 400 INR were charged for this.
On the way to the top of Bahubali hill ...
There were so many inscriptions on the way to Bahubali, most of them were written on old kannada and Marathi. I was telling my friends there should be a wonderful language compiler for all the indian old and new languages which will convert from any to any; dreaming that at least our next generations will decode the photos we have taken for all those inscriptions to understand the history. There were many theerthankaras idols placed behind the Baahubali idol.

For every 12 years there will be "MahaMastakabhishekam" performed for this huge idol; in which they will perform abhishekam with ghee, milk, gold coins and saffron. It is a spectacular ceremony. the next will be in the year 2018. We skipped to visit the chandragiri to visit other places in plan.

Coconut water is my all time relaxing technique which again I applied after getting down from the hill and quickly started Off to Halebidu which is 78 km from Shravanabelagola.On the way we stopped for Lunch in Hasan town. Food was average though we have choosen the best hotel in the town and in the heavey rain itself we started to Halebedu to save the time.

Halebedu wiki 

By the time we reached Halebedu, climate was good and entered the uncompleted, Hoyasaleswara temple constructed by Hoyasala dinesty kings ...Halebedu which was previously called Dorasamudra or Dwarasamudra) was the regal capital of the Hoysala Empire in the 12th century. Surprising thing to know was the word "Halebedu" means ruined city. Guide was many times telling that it was invaded by Bahamani sultan and other Muslim kings who ruled the near by places. But how come they would have thought of invading this much great sculptures.

One of the best sculptures @ Halebedu
In this place there were two uncompleted Hoysaleshawara and Kedareshwara temples  and before them two big bulls (Nandi's) and also one big lake called as Dwara samudhra which means entrance from ocean by which the name of the village too. The two big monolithic Nandi's and many sculptures in the temple were made of soap stone or Chloritic Schis. One will definitely gets amazed while seeing the beauty and understand the view of artists who carved these sculptures.There are beautiful and numerous sculptures surrounding the temple as well as inside the temple. I can't express the fineness of these sculptures one has to see and feel it. There is one archeological museum inside the temple premises which has few invaded stones and uncompleted sculptures.
@ Halebedu temple ..Whole group
Belur wiki 
We reached Beluru around at 4:30 PM; it is just 16 KMs from Halibedu. The temple here was Chenna Kesawa swamy (Good looking Vishnu in meaning). Unfortunately the temple was closed for that day. Unlike Halibedu, Beluru temples were 100 % completed. Even Sri krishna devaraya has done some renovations to this temple during his kingdom.

King Vishnuvardana and his qween Shantala devi who has paid attention and developed these two places.As like all the temples there was pushkarani in this temple complex as well. The surprising stuff is that, there was one prototype temple in the same complex which we can see for the original temple. The star base for both prototye and main temple was really powerful. The sculpture and temple architecture is simply superb. I don't think modern artists can build this kind of fine artistic monuments just with hands.The temple is one of the finest examples of Hoysala architecture, there is no doubt for this.
at Belur Temple ..
Belur and Halebedu architecture reminded me my trip to Somanathapur , because the architecture is same in these three temples, the fine ness and techniques in carving these sculputures are same they look almost same but different in views of different artists. The imagination and views of the artists who carved all these sculptures are from our Puranas, Itihaasas, technology, culture, Habits, Intersts to Kamasutras.

One line to say about these two places is "Belur - Halibedu are pride to India in terms of its culture and its standards". I never imagined 2D and 3D views in the sculptures till I see this place. Hats-off to the creativity of architects and artists involved in this great fine monuments and sculptures in this temple.

Finally we started our retrun journey to Bangalore around at  7 PM and everybody took rest and reached our places almost by mid-night.
It was a good trip after long time for all of us....looking for some thing different this time .. Let's wait and see...
At Belur temple ..

Read more


DB2 database back up and restore commands and using db2cc tool unix and windows

DB2 database back up and restore commands & using db2cc tool UNIX and windows

This post briefs the steps to take back up of a database in DB2.
There are mutiple ways to take database back up in DB2. I felt the easiest way of taking back up for a database is using the DB2CC tool (DB2 control center tool). There the process or steps to take back up or restore a particular DB is pretty straight and easy.

Yet another simple process to take back up is commands in the command line.

To take back up : 
  db2inst1@nc145016:/opt> db2 BACKUP DATABASE CDSDB TO "/opt/BKP"

                           Backup successful. The timestamp for this backup image is : 20100709051851
However you can see the command generated during the back up taking process using db2cc tool. 
It looks some thing like below ...
-- The following commands may not run as expected in a multi database partition environment if executed from a single script.

-- Quiesce Database
-- Run on any database partition.
CONNECT TO CDSDB;
QUIESCE DATABASE IMMEDIATE FORCE CONNECTIONS;
CONNECT RESET;

-- Backup Database Partition Grouping 1
-- Run on database partition(s): 0
BACKUP DATABASE CDSDB TO "/opt/BKP" WITH 2 BUFFERS BUFFER 1024 PARALLELISM 1 WITHOUT PROMPTING;

-- Unquiesce Database
-- Run on any database partition.
CONNECT TO CDSDB;
UNQUIESCE DATABASE;
CONNECT RESET;

To restore a database : 
A simple command looks like below to restore a particular database.
 db2inst1@nc145016:/opt/BKP> db2 RESTORE DATABASE CDSDB FROM "/opt/BKP" TAKEN AT 20100708081818
                               DB20000I  The RESTORE DATABASE command completed successfully.

And where as the db2cc generated SQL query may look like some thing below 

RESTORE DATABASE CDSDB FROM "/opt/BKP" TAKEN AT 20100708081818 WITH 2 BUFFERS BUFFER 1024 PARALLELISM 1 WITHOUT PROMPTING;

Hope this helps .. any related information to db2 database back up / restore process can be posted to this in comments.

Reference : [1] [2] [3]

Read more


Not in Usage for DB2 SQL select subqueries

Here is a sample SQL queries to compare the usage of "NOT IN" in Oracle and DB2..

Usually to filter few rows from the result of one SELECT query we combine another SELECT query with NOT IN phrase.

Example : 1  in Oracle
SELECT * FROM emp WHERE rownum=1 AND rowid NOT IN(SELECT rowid FROM emp WHERE rownum < 10);

Example 2 : in DB2
SELECT FD.SERVER_NAME FROM CDSSCHEMA.DEPOT_SERVER FD where FD.SERVER_NAME NOT IN (SELECT DS.SERVER_NAME FROM CDSSCHEMA.TARGETLIST_MAP TM, CDSSCHEMA.TARGETLIST T, CDSSCHEMA.DEPOT_SERVER DS, CDSSCHEMA.TARGET_SERVER TS WHERE TM.PACKAGE_ID='1278328705570' AND TM.TARGETLIST_ID=T.TARGETLIST_ID AND DS.SERVER_ID=TS.SERVER_ID AND TS.TARGETLIST_ID=T.TARGETLIST_ID ORDER BY DS.SERVER_NAME)

The above query return the list of depot server names which are not in the second select queury.

Read more


shell script to print/check directory permissions on Unix

Shell script to print/check directory permissions on Unix
Here is a small shell script which will print a directory permissions and other details...
Basically I want to check whether a directory has the read write permissions for the user?
I am using here a simple commonsense that a read write permissions will make the octal permissions of it more than 600 for sure .. that's it.
d rwx rwx rwx
d rw- --- ---
   420 000 000
   6     0      0
   rwx r-x r-x
   7 5 5
So it should be always greater than 600 for a directory to have read write permissions always.
Basically I'm using stat tool to find the permissions of a dir
Ex : check stat for /opt/a
nc184120:/opt # stat /opt/a
  File: `/opt/a'
  Size: 48              Blocks: 0          IO Block: 4096   directory
Device: 802h/2050d      Inode: 101912      Links: 2
Access: (0155/d--xr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2010-07-01 22:53:59.845347264 -0700
Modify: 2010-07-01 01:45:43.769709152 -0700
Change: 2010-07-01 01:46:14.790993200 -0700

So the above script doesn't have read or write permissions.

Shell script  :
nc184120:/opt # cat per.sh
dir="/opt/a"
echo "Checking the permissions for $dir"
stat $dir
echo "##############################################"
if [ `stat -c "%a" $dir` -ge 600 ] ; then
     echo "$dir has Read Write permissions."
else
     echo "$dir has no read write permissions."
fi

and the output looks like below ...
nc184120:/opt # ./per.sh
Checking the permissions for /opt/a
  File: `/opt/a'
  Size: 48              Blocks: 0          IO Block: 4096   directory
Device: 802h/2050d      Inode: 101912      Links: 2
Access: (0155/d--xr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2010-07-01 22:53:59.845347264 -0700
Modify: 2010-07-01 01:45:43.769709152 -0700
Change: 2010-07-01 01:46:14.790993200 -0700
##############################################
/opt/a has no read write permissions.


Read more


Vedam - Analysis & Review


The most expected and awaiting movie for me; first time I saw the movie just a little bit ahead from the second half; but second time able to see the full length. overall movie is up to my expectation and it was again a touching story like Krish's debut movie "Gamyam". Many people say "it is experimental" ,"it is a good movie" and "It is challenging" but my feeling is that it is just director's gut feelings and his moral reasons out his life learnings to educate people. The major scenes which moves any of the audience are "Allu arjun trying to rob the money from the old man", "When old man find his money the expressions and the music" and the final scene "When old man pays back the interest amount and patel leaving the kid". Through out the movie I never see Allu arjun, Anushka, Old man or Manchu manoj but just the characters cable raju, Saroja, Ramulu and Vivek(A Typical aspiring rock star) what else as a director krish wants, its purely a directors movie and its a honest success for him.

The noble intention to re-invent the human in all of us by Krish with his "VEDAM" is great. By looking at the trailer it self many wise people predicted the story;  and yes they are correct ! It was a story of five typical different Indians aspiring for different ways in some other way money is the need for most  of them. But I was seriously thinking about Krish; How he manages to score a hit as it is just second movie. Any body by seeing the Anushka in the trailers thinks that movie is fully commercial but krish never gave up his sensitivity to humanism. Prior to the movie release itself people started gossiping about "Vedam"; that the theme behind the movie was terrorism as like "Gamyam" takes theme of Naxalism. But my feeling is "Vedam" is a movie to re-invent the humanism in humans so theme is "Humanism". The patriotism attached to the climax is to high-light the humanism in my feeling. After watching the Prasthanam my only expectation was on "Vedam" and it will be really great if people really watch this movie with true sense of humanism.

Don't know what life lessons impacted krish in his past? the way he pictures the differences between rich and poor in his movies is simply clear and true reflecting the reality. The dialogues about the death people funeral by Allu arjun clarifies the differences between rich and poor.
And many other dialogues are thought provoking ones.
"Perugu vada lo perugu undi kada ani Pulihora lo puli untadaa ??" this dialogue by arjun to Sage(krish was in that role) sound funny but the meaning behind that has so much depth.

"Basti lo pothe ganta lo ettu taaru ; ade akkada chaste rendu rojulu frig lo unchutaaru, manchi gaa chaavalanna dabbu lo puttali ra .."
And coming to songs, all are good Keeravaani surprised me by writing four songs in this movie, and as usual Seetaa rama sastry sirs songs is having so much depth in his lyrics and it is also good.
"Neetho nuvvu kalahisthu
nityam ninu nuvve gelipisthu
samayam pai chirakalam cheragani santakanni pettu "
........

Again hats-off to Sastry sir.

Kudos to krish and his crew.
Special thanks to Allu arjun and Manchu manoj to make it happen ...
P.S : A guest appearance role can have fights, songs and scenes through out the movie and it has impact on climax scene as well. Then what does a real Guest appearance role means. May be manoj did not even tell his name at climax to arjun as his role is guest role.

Read more


Java code to connect DB2 Type 4 driver db2jcc.jar

JAVA sample code to connect to DB2 Database using Type 4 Driver

The below sample code shows the simple way of making connection to a DB2 Server Database exists on a remote machine with out installing any db2 client on your machine. But all we need to have is Type 4 drivers to make this connection which we can use by pointing to the db2jcc.jar and db2jcc_license_cu.jar.
All we need to do is point the java class path to find this jars, in case of eclipse users configure the build path and these 2 jars as external jars from the path they located to the project.   change the Host name, port, user name and password like details in the below program and run accordingly.

Syntax for the connection string : 
 DriverManager.getConnection
                 ("jdbc:db2j:net://<HOSTNAME>:<Port>/<Database name>,"<User name>","<Password>");

Sample connection string :
 DriverManager.getConnection
                 ("jdbc:db2j:net://nc184120.tivlab.austin.ibm.com:50001/CDSDB","db2inst1","db2inst1");

The following is the sample code.... 

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Java2DB2 {
public static void main(String[] args)
{
try
{
// load the DB2 Driver
Class.forName("com.ibm.db2.jcc.DB2Driver");
// establish a connection to DB2
Connection db2Conn =
DriverManager.getConnection
("jdbc:db2j:net://nc184120.tivlab.austin.ibm.com:50001/CDSDB","db2inst1","db2inst1");
// use a statement to gather data from the database
Statement st = db2Conn.createStatement();
String myQuery = "SELECT * FROM CDSSCHEMA.ACL_ADMIN";
// execute the query
ResultSet resultSet = st.executeQuery(myQuery);
// cycle through the resulSet and display what was grabbed
while (resultSet.next())
{
String name = resultSet.getString("USER_NAME");
String id = resultSet.getString("USER_ID");
System.out.println("User Name: " + name);
System.out.println("User ID: " + id);
System.out.println("-------------------------------");
}
// clean up resources
resultSet.close();
st.close();
db2Conn.close();
}
catch (ClassNotFoundException cnfe)
{
cnfe.printStackTrace();
}
catch (SQLException sqle)
{
sqle.printStackTrace();
}
}
}


Happy DB2 connectivity :)
Reference : [1]

Read more


XML data to objects/classes JAVA parsing (Data binding - JIBX)

XML file parsing using JIBX tool - XML Data binding to Objects

Some times we may require to parse a given XML file to populate the data in objects.
So here the only source we have is a sample XML file, nothing else not even a xsd file available.
Requirement description :
You are given just one sample XML file which needs to be parsed and populate the data from XML file to java class objects.
There is no XSD (XML schema definition) file available.
Sample XML file contents :

Solution :
 The solution I followed for this is using the jibx tool to reduce the code burden.
 JIBX is one of the best xml parsing tool for xml data binding.

So all we need to do; to use jibx tool we have to do the below mentioned 5 steps.
1. Analyze the sample.xml
2. write the binding.xml.
3. Write the classes identified.
4. Compile using build.xml.
5. Write main method to parse the xml file and show the data.

Analyze the sample.xml :
Read carefully and observe the pattern of data it contains.
Example below
<?xml version="1.0" encoding="UTF-8"?>
<results
        xmlns="urn:www-collation-com:1.0"
        xmlns:coll="urn:www-collation-com:1.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="urn:www-collation-com:1.0
              urn:www-collation-com:1.0/results.xsd">

    <ComputerSystem array="1" guid="0A59DB143A8B3B0F9385FE6A3E0BE095" xsi:type="coll:com.collation.platform.model.topology.sys.sun.SunSPARCUnitaryComputerSystem">
        <fqdn>islrpbssn03.in.ibm.com</fqdn>
        <type>ComputerSystem</type>
        <OSRunning guid="8B9EF833438F3F769DF1C6B6F8EB6704" xsi:type="coll:com.collation.platform.model.topology.sys.sun.Solaris">
            <OSConfidence>100</OSConfidence>
            <OSName>SunOS</OSName>
            <OSVersion>5.10</OSVersion>
            <OSMode>64-bit sparcv9 applications,    vis2 vis ,32-bit sparc applications,    vis2 vis v8plus div32 mul32</OSMode>
        </OSRunning>
        <ipInterfaces array="1"
            guid="B0DB02C0C1D03E248FCCF97D3744EFDF"
            lastModified="1270881893121"
            parent="0A59DB143A8B3B0F9385FE6A3E0BE095" xsi:type="coll:com.collation.platform.model.topology.net.IpInterface">
            <ipAddress guid="0188E1E8633E3F5C849E2454ED7F92A2" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Address"/>
            <ipNetwork guid="3856A334B3D6306E9A2C5CEC97357808" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Network"/>
            <l2Interface guid="1FF6C43DFD7A3D658939894CD2840FBB" xsi:type="coll:com.collation.platform.model.topology.net.L2Interface"/>
            <displayName>9.126.85.190</displayName>
            <bidiFlag>3</bidiFlag>
        </ipInterfaces>
        <ipInterfaces array="2"
            guid="4CE10626AD1F35879F2BFEFB911C0596"
            lastModified="1270881893058"
            parent="0A59DB143A8B3B0F9385FE6A3E0BE095" xsi:type="coll:com.collation.platform.model.topology.net.IpInterface">
            <ipAddress guid="A5B55BF06F4F3568B0A3A08566776E34" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Address"/>
            <ipNetwork guid="91E4DC01B2B93F1C9733720535C3250A" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Network"/>
            <l2Interface guid="C8538176AA8435568BAE99C81BDEFADE" xsi:type="coll:com.collation.platform.model.topology.net.L2Interface"/>
            <displayName>127.0.0.1</displayName>
            <bidiFlag>3</bidiFlag>
        </ipInterfaces>
    </ComputerSystem>


    <ComputerSystem array="2" guid="1AE1BAE9EA5F37E3891BA093962E80D2" xsi:type="coll:com.collation.platform.model.topology.sys.linux.LinuxUnitaryComputerSystem">
        <fqdn>islrpbeixn50.in.ibm.com</fqdn>
        <type>ComputerSystem</type>
        <OSRunning guid="70081092A0FB3F3CBF28A93850781F8B" xsi:type="coll:com.collation.platform.model.topology.sys.linux.Linux">
            <OSConfidence>100</OSConfidence>
            <OSName>Linux</OSName>
            <OSVersion>SUSE Linux Enterprise Server 10 (i586)</OSVersion>
            <OSMode>64-bit</OSMode>
        </OSRunning>
        <ipInterfaces array="1"
            guid="C1E26AF496CB3E6898D4C681E7D4890F"
            lastModified="1271145535996"
            parent="1AE1BAE9EA5F37E3891BA093962E80D2" xsi:type="coll:com.collation.platform.model.topology.net.IpInterface">
            <ipAddress guid="BBF92BDB2A9333B999AA5D1F3D2D7DB2" xsi:type="coll:com.collation.platform.model.topology.net.IpV6Address"/>
            <ipNetwork guid="91E4DC01B2B93F1C9733720535C3250A" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Network"/>
            <l2Interface guid="29D627F80C0635BD9FAD32842E97EC4B" xsi:type="coll:com.collation.platform.model.topology.net.L2Interface"/>
            <displayName>0:0:0:0:0:0:0:1</displayName>
            <bidiFlag>3</bidiFlag>
        </ipInterfaces>
        <ipInterfaces array="2"
            guid="364EF12203853318BCAF2BE2DB279B67"
            lastModified="1271145535918"
            parent="1AE1BAE9EA5F37E3891BA093962E80D2" xsi:type="coll:com.collation.platform.model.topology.net.IpInterface">
            <ipAddress guid="A5B55BF06F4F3568B0A3A08566776E34" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Address"/>
            <ipNetwork guid="91E4DC01B2B93F1C9733720535C3250A" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Network"/>
            <l2Interface guid="29D627F80C0635BD9FAD32842E97EC4B" xsi:type="coll:com.collation.platform.model.topology.net.L2Interface"/>
            <displayName>127.0.0.1</displayName>
            <bidiFlag>3</bidiFlag>
        </ipInterfaces>
        <ipInterfaces array="3"
            guid="99FE67EE21B733D18D730D9EB9668D9C"
            lastModified="1271145535964"
            parent="1AE1BAE9EA5F37E3891BA093962E80D2" xsi:type="coll:com.collation.platform.model.topology.net.IpInterface">
            <ipAddress guid="8ABCC5879A4532DFAE9E8341D10F01B6" xsi:type="coll:com.collation.platform.model.topology.net.IpV6Address"/>
            <ipNetwork guid="91E4DC01B2B93F1C9733720535C3250A" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Network"/>
            <l2Interface guid="802D599BA72A3C84A78B2123F0E6DBB2" xsi:type="coll:com.collation.platform.model.topology.net.L2Interface"/>
            <displayName>fe80:0:0:0:20e:cff:fe67:5433</displayName>
            <bidiFlag>3</bidiFlag>
        </ipInterfaces>
        <ipInterfaces array="4"
            guid="BA733238179833AD91D43E542B9F93CC"
            lastModified="1271145535980"
            parent="1AE1BAE9EA5F37E3891BA093962E80D2" xsi:type="coll:com.collation.platform.model.topology.net.IpInterface">
            <ipAddress guid="DB0FFF95E752314596831ACC9A0FC100" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Address"/>
            <ipNetwork guid="91E4DC01B2B93F1C9733720535C3250A" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Network"/>
            <l2Interface guid="802D599BA72A3C84A78B2123F0E6DBB2" xsi:type="coll:com.collation.platform.model.topology.net.L2Interface"/>
            <displayName>9.184.66.239</displayName>
            <bidiFlag>3</bidiFlag>
        </ipInterfaces>
    </ComputerSystem>


    <ComputerSystem array="3" guid="5DB5CC25116C39C484C69F4330FEFF86" xsi:type="coll:com.collation.platform.model.topology.sys.aix.AixUnitaryComputerSystem">
        <fqdn>islrpbixv06.in.ibm.com</fqdn>
        <type>ComputerSystem</type>
        <OSRunning guid="6CD3AF45BE603572ABF97B4B1D261D96" xsi:type="coll:com.collation.platform.model.topology.sys.aix.Aix">
            <OSConfidence>100</OSConfidence>
            <OSName>AIX</OSName>
            <OSVersion>5.3.0.0</OSVersion>
            <OSMode>64-bit</OSMode>
        </OSRunning>
        <ipInterfaces array="1"
            guid="E518A4B9197138D0AB7A5671A7897A77"
            lastModified="1270881954418"
            parent="5DB5CC25116C39C484C69F4330FEFF86" xsi:type="coll:com.collation.platform.model.topology.net.IpInterface">
            <ipAddress guid="A5B55BF06F4F3568B0A3A08566776E34" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Address"/>
            <ipNetwork guid="91E4DC01B2B93F1C9733720535C3250A" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Network"/>
            <l2Interface guid="2038D4670E123063A7668E8AB92761C2" xsi:type="coll:com.collation.platform.model.topology.net.L2Interface"/>
            <displayName>127.0.0.1</displayName>
            <bidiFlag>3</bidiFlag>
        </ipInterfaces>
        <ipInterfaces array="2"
            guid="ADDB51DDC2B73109ACD8374768D17BBE"
            lastModified="1270881954214"
            parent="5DB5CC25116C39C484C69F4330FEFF86" xsi:type="coll:com.collation.platform.model.topology.net.IpInterface">
            <ipAddress guid="1832ABD3CD2D31E586A8FA14542B5C44" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Address"/>
            <ipNetwork guid="3FE22AF17C5F309CAB28E4C3FDBACB76" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Network"/>
            <l2Interface guid="D8AC8F9F2A8433149A5CA169F466AAE4" xsi:type="coll:com.collation.platform.model.topology.net.L2Interface"/>
            <displayName>9.122.166.118</displayName>
            <bidiFlag>3</bidiFlag>
        </ipInterfaces>
        <ipInterfaces array="3"
            guid="529EED8B732333188CFD3490DA1922C5"
            lastModified="1270881953980"
            parent="5DB5CC25116C39C484C69F4330FEFF86" xsi:type="coll:com.collation.platform.model.topology.net.IpInterface">
            <ipAddress guid="BBF92BDB2A9333B999AA5D1F3D2D7DB2" xsi:type="coll:com.collation.platform.model.topology.net.IpV6Address"/>
            <ipNetwork guid="91E4DC01B2B93F1C9733720535C3250A" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Network"/>
            <l2Interface guid="2038D4670E123063A7668E8AB92761C2" xsi:type="coll:com.collation.platform.model.topology.net.L2Interface"/>
            <displayName>0:0:0:0:0:0:0:1</displayName>
            <bidiFlag>3</bidiFlag>
        </ipInterfaces>
    </ComputerSystem>


    <ComputerSystem array="4" guid="6E4C78F0B9463420ADBC21A2658AA22A" xsi:type="coll:com.collation.platform.model.topology.sys.linux.LinuxUnitaryComputerSystem">
        <fqdn>rt4.in.ibm.com</fqdn>
        <type>ComputerSystem</type>
        <OSRunning guid="41693E27B5123A56B946B3DAA7153246" xsi:type="coll:com.collation.platform.model.topology.sys.linux.Linux">
            <OSConfidence>100</OSConfidence>
            <OSName>Linux</OSName>
            <OSVersion>Red Hat Enterprise Linux Server release 5.2 (Tikanga)</OSVersion>
            <OSMode>64-bit</OSMode>
        </OSRunning>
        <ipInterfaces array="1"
            guid="BD81B78B00F431F28E45B9903C673FE4"
            lastModified="1270881834871"
            parent="6E4C78F0B9463420ADBC21A2658AA22A" xsi:type="coll:com.collation.platform.model.topology.net.IpInterface">
            <ipAddress guid="A5B55BF06F4F3568B0A3A08566776E34" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Address"/>
            <ipNetwork guid="91E4DC01B2B93F1C9733720535C3250A" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Network"/>
            <l2Interface guid="18F19B1E5BCF33D8B294658B89623E3A" xsi:type="coll:com.collation.platform.model.topology.net.L2Interface"/>
            <displayName>127.0.0.1</displayName>
            <bidiFlag>3</bidiFlag>
        </ipInterfaces>
        <ipInterfaces array="2"
            guid="361035ED31F73386A96E01DB59CF2377"
            lastModified="1270881834761"
            parent="6E4C78F0B9463420ADBC21A2658AA22A" xsi:type="coll:com.collation.platform.model.topology.net.IpInterface">
            <ipAddress guid="D4B04242C8063DD0A15FC4FA539C2886" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Address"/>
            <ipNetwork guid="C729C2ED74793124B410B3E08FC4F366" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Network"/>
            <l2Interface guid="F9307994411B350DBCA8C2BD4C983BC8" xsi:type="coll:com.collation.platform.model.topology.net.L2Interface"/>
            <displayName>9.184.64.244</displayName>
            <bidiFlag>3</bidiFlag>
        </ipInterfaces>
        <ipInterfaces array="3"
            guid="618CE77DCA1630728FE9F975F5D92E34"
            lastModified="1270881834839"
            parent="6E4C78F0B9463420ADBC21A2658AA22A" xsi:type="coll:com.collation.platform.model.topology.net.IpInterface">
            <ipAddress guid="BBF92BDB2A9333B999AA5D1F3D2D7DB2" xsi:type="coll:com.collation.platform.model.topology.net.IpV6Address"/>
            <ipNetwork guid="91E4DC01B2B93F1C9733720535C3250A" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Network"/>
            <l2Interface guid="18F19B1E5BCF33D8B294658B89623E3A" xsi:type="coll:com.collation.platform.model.topology.net.L2Interface"/>
            <displayName>0:0:0:0:0:0:0:1</displayName>
            <bidiFlag>3</bidiFlag>
        </ipInterfaces>
        <ipInterfaces array="4"
            guid="D0C5FD62F70D39D79517C5957A08C012"
            lastModified="1270881835058"
            parent="6E4C78F0B9463420ADBC21A2658AA22A" xsi:type="coll:com.collation.platform.model.topology.net.IpInterface">
            <ipAddress guid="D4E59986D65530F49E2882A857002FF3" xsi:type="coll:com.collation.platform.model.topology.net.IpV6Address"/>
            <ipNetwork guid="91E4DC01B2B93F1C9733720535C3250A" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Network"/>
            <l2Interface guid="F9307994411B350DBCA8C2BD4C983BC8" xsi:type="coll:com.collation.platform.model.topology.net.L2Interface"/>
            <displayName>fe80:0:0:0:250:56ff:feac:255f</displayName>
            <bidiFlag>3</bidiFlag>
        </ipInterfaces>
    </ComputerSystem>


    <ComputerSystem array="5" guid="9AB5DEF9F5FD3DADA2616230B605A250" xsi:type="coll:com.collation.platform.model.topology.sys.linux.LinuxUnitaryComputerSystem">
        <fqdn>rt3.in.ibm.com</fqdn>
        <type>ComputerSystem</type>
        <OSRunning guid="C75FD5FBA18D31C0ADD033BB84254600" xsi:type="coll:com.collation.platform.model.topology.sys.linux.Linux">
            <OSConfidence>100</OSConfidence>
            <OSName>Linux</OSName>
            <OSVersion>Red Hat Enterprise Linux Server release 5.2 (Tikanga)</OSVersion>
            <OSMode>64-bit</OSMode>
        </OSRunning>
        <ipInterfaces array="1"
            guid="006D494967D035D4BE14AB9BA9B35535"
            lastModified="1270881877402"
            parent="9AB5DEF9F5FD3DADA2616230B605A250" xsi:type="coll:com.collation.platform.model.topology.net.IpInterface">
            <ipAddress guid="EDC5FDD18141344E8C38D0634DB3384E" xsi:type="coll:com.collation.platform.model.topology.net.IpV6Address"/>
            <ipNetwork guid="91E4DC01B2B93F1C9733720535C3250A" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Network"/>
            <l2Interface guid="F739F58377043960813E3F1DFFEF9F79" xsi:type="coll:com.collation.platform.model.topology.net.L2Interface"/>
            <displayName>fe80:0:0:0:250:56ff:feac:3d65</displayName>
            <bidiFlag>3</bidiFlag>
        </ipInterfaces>
        <ipInterfaces array="2"
            guid="934DDB05B9873AE696C77F8AFE6E52A7"
            lastModified="1270881877668"
            parent="9AB5DEF9F5FD3DADA2616230B605A250" xsi:type="coll:com.collation.platform.model.topology.net.IpInterface">
            <ipAddress guid="BBF92BDB2A9333B999AA5D1F3D2D7DB2" xsi:type="coll:com.collation.platform.model.topology.net.IpV6Address"/>
            <ipNetwork guid="91E4DC01B2B93F1C9733720535C3250A" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Network"/>
            <l2Interface guid="693C859D351830E1AE777C9025B500A6" xsi:type="coll:com.collation.platform.model.topology.net.L2Interface"/>
            <displayName>0:0:0:0:0:0:0:1</displayName>
            <bidiFlag>3</bidiFlag>
        </ipInterfaces>
        <ipInterfaces array="3"
            guid="7A0CAE72A3663716AB1232D870D80EDE"
            lastModified="1270881877589"
            parent="9AB5DEF9F5FD3DADA2616230B605A250" xsi:type="coll:com.collation.platform.model.topology.net.IpInterface">
            <ipAddress guid="A5B55BF06F4F3568B0A3A08566776E34" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Address"/>
            <ipNetwork guid="91E4DC01B2B93F1C9733720535C3250A" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Network"/>
            <l2Interface guid="693C859D351830E1AE777C9025B500A6" xsi:type="coll:com.collation.platform.model.topology.net.L2Interface"/>
            <displayName>127.0.0.1</displayName>
            <bidiFlag>3</bidiFlag>
        </ipInterfaces>
        <ipInterfaces array="4"
            guid="91CD76C8B641385B97EFA94772ABB624"
            lastModified="1270881877652"
            parent="9AB5DEF9F5FD3DADA2616230B605A250" xsi:type="coll:com.collation.platform.model.topology.net.IpInterface">
            <ipAddress guid="5F42ACC1D9363EB6920C240A4FC1ACE2" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Address"/>
            <ipNetwork guid="C729C2ED74793124B410B3E08FC4F366" xsi:type="coll:com.collation.platform.model.topology.net.IpV4Network"/>
            <l2Interface guid="F739F58377043960813E3F1DFFEF9F79" xsi:type="coll:com.collation.platform.model.topology.net.L2Interface"/>
            <displayName>9.184.64.243</displayName>
            <bidiFlag>3</bidiFlag>
        </ipInterfaces>
    </ComputerSystem>
</results>


binding.xml :
Create binding.xml file by analyzing the given xml file is the crucial part of this solution.
The documentation provided will help in writing binding.xml file for your requirement. see below binding.xml for the above sample.xml. If at all we have xsd file as well it would be easy to write the binding.xml. And we can understand the ways of writing this binding.xml by looking at most possible examples explained in jibx site.

<binding>
    <mapping name="results" class="com.ibm.xmlbind.Results">
        <collection field="computerSystems"
            item-type="com.ibm.xmlbind.ComputerSystem" />
    </mapping>
    <mapping name="ComputerSystem"
        class="com.ibm.xmlbind.ComputerSystem">
        <value name="fqdn" field="fqdn" />
        <value name="type" field="type" />
        <value name="guid" style="attribute" field="guid" />
        <structure name="OSRunning" field="osRunning" usage="optional">
            <value name="OSConfidence" field="osConfidence" usage="optional"/>
            <value name="OSName" field="osName" usage="optional"/>
            <value name="OSVersion" field="osVersion" usage="optional"/>
            <value name="OSMode" field="osMode" usage="optional"/>
        </structure>
        <collection field="ipInterfaces"
            item-type="com.ibm.xmlbind.IPInterfaces" />
    </mapping>
    <mapping name="ipInterfaces" class="com.ibm.xmlbind.IPInterfaces">
        <value name="ipAddress" field="ipAddress" usage="optional"/>
        <value name="ipNetwork" field="ipNetwork" usage="optional"/>
        <value name="l2Interface" field="l2Interface" usage="optional"/>
        <value name="displayName" field="displayName" usage="optional"/>
        <value name="bidiFlag" field="bidiFlag" usage="optional"/>
    </mapping>
</binding>

Creating the classes :
By closely observing the xml file we have to write the classes and their setter and getter methods.
See the classes identified for the above sample.xml below ...

ComputerSystems.java :
package com.ibm.xmlbind;

import java.util.ArrayList;

public class ComputerSystem {

    private String fqdn;

    private String type;

    private String guid;

    private OSRunning osRunning;

    private ArrayList ipInterfaces;

    public String getFqdn() {
        return fqdn;
    }

    public void setFqdn(String fqdn) {
        this.fqdn = fqdn;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public OSRunning getOsRunning() {
        return osRunning;
    }

    public void setOsRunning(OSRunning osRunning) {
        this.osRunning = osRunning;
    }

    public ArrayList getIpInterfaces() {
        return ipInterfaces;
    }

    public void setIpInterfaces(ArrayList ipInterfaces) {
        this.ipInterfaces = ipInterfaces;
    }

    public String getGuid() {
        return guid;
    }

    public void setGuid(String guid) {
        this.guid = guid;
    }

}
IPinterfaces.java:
package com.ibm.xmlbind;

public class IPInterfaces {

    private String ipAddress;

    private String ipNetwork;

    private String l2Interface;

    private String displayName;

    private String bidiFlag;

    public String getBidiFlag() {
        return bidiFlag;
    }

    public void setBidiFlag(String bidiFlag) {
        this.bidiFlag = bidiFlag;
    }

    public String getDisplayName() {
        return displayName;
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    public String getIpAddress() {
        return ipAddress;
    }

    public void setIpAddress(String ipAddress) {
        this.ipAddress = ipAddress;
    }

    public String getL2Interface() {
        return l2Interface;
    }

    public void setL2Interface(String interface1) {
        l2Interface = interface1;
    }

    public String getIpNetwork() {
        return ipNetwork;
    }

    public void setIpNetwork(String ipNetwork) {
        this.ipNetwork = ipNetwork;
    }

}
OSRunning.java:
package com.ibm.xmlbind;

public class OSRunning {
    private String osConfidence;

    private String osName;

    private String osVersion;
   
    private String osMode;

    public String getOsMode() {
        return osMode;
    }

    public void setOsMode(String osMode) {
        this.osMode = osMode;
    }

    public String getOsConfidence() {
        return osConfidence;
    }

    public void setOsConfidence(String osConfidence) {
        this.osConfidence = osConfidence;
    }

    public String getOsName() {
        return osName;
    }

    public void setOsName(String osName) {
        this.osName = osName;
    }

    public String getOsVersion() {
        return osVersion;
    }

    public void setOsVersion(String osVersion) {
        this.osVersion = osVersion;
    }

    @Override
    public String toString() {
        return "OSConfidence : " + osConfidence + " -- " +
        "OSName : " + osName + " -- " +
        "OSVersion : " + osVersion + " -- " +
        "OSMode : " + osMode;       
    }
   
   

}
Results.java :
package com.ibm.xmlbind;

import java.util.ArrayList;

public class Results {
   
    private ArrayList computerSystems;

    public ArrayList getComputerSystems() {
        return computerSystems;
    }

    public void setComputerSystems(ArrayList computerSystems) {
        this.computerSystems = computerSystems;
    }
   
   
}

Compiling :
once binding.xml and the classes are ready it is required to compile those to map the classes and XML tags.
For compiling this we can use the sample build.xml shown below.
build.xml :
<?xml version="1.0"?>
<project name="xmlbind" default="compile" basedir="..">
    <property name="root-dir" value="${basedir}/Build" />
    <property name="lib" value="${root-dir}/lib" />
    <property name="binding-file" value="${basedir}/binding.xml" />
    <target name="setclasspath">
        <path id="bindpath">
            <pathelement location="${root-dir}" />
            <pathelement location="${basedir}/bin" />
            <pathelement location="${lib}/jibx-bind.jar" />
            <pathelement location="${lib}/bcel.jar" />
            <pathelement location="${basedir}/lib/jibx-run.jar" />
            <pathelement location="${basedir}/lib/xpp3.jar" />
        </path>
    </target>
    <!-- Delete class files for a single example -->
    <target name="clean">
        <delete quiet="true">
            <fileset dir="${basedir}/bin" includes="**/JiBX_*.class" />
        </delete>
    </target>

    <!-- Create Binding classes -->
    <target name="compile" depends="clean,setclasspath">
        <java classname="org.jibx.binding.Compile" fork="yes" dir="${root-dir}" failonerror="true">
            <classpath refid="bindpath" />
            <arg value="${binding-file}" />
        </java>
    </target>
    <!-- Generate classes and binding.xml for given xsd file -->
    <target name="run-bind" depends="setclasspath">
        <java classname="" fork="yes" dir="${root-dir}" failonerror="true">
            <classpath refid="bindpath" />
            <arg value="${binding-file}" />
        </java>
    </target>
</project>


 
Main methods to parse XML file:
The below sample code parses the given XML file and prints the data in the objects.
package com.ibm.test;

import java.io.FileInputStream;

import org.jibx.runtime.*;

import com.ibm.util.Utils;
import com.ibm.xmlbind.*;

public class BindTest {
    public static void main(String[] args) throws Exception {
        IBindingFactory bfact = BindingDirectory.getFactory(Results.class);
        IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
        Results obj = (Results) uctx.unmarshalDocument(new FileInputStream(
                Utils.removeXMLNamespaces("sample.xml")), null);
        for (int i = 0; i < obj.getComputerSystems().size(); i++) {           
            System.out.println("ComputerSystem : " + (i+1));
            System.out.println("--------------------------------------------");
            print((ComputerSystem) obj.getComputerSystems().get(i));
        }
        }
       
   
    private static void print(ComputerSystem sys) {
        System.out.println("  GUID of this Computer system: " + sys.getGuid());
        System.out.println("  fqdn : " + sys.getFqdn());
        System.out.println("  type : " + sys.getFqdn());
        System.out.println("  OSRunning : " + sys.getOsRunning());
       
    }
}
Folder structure in the Eclipse workspace:

Read more

Translate

Enter your email address:

Buffs ...

Visitors


hits counter
View My StatsCheck Google Page Rank

Add to Google Reader or Homepage

Bookmark and Share

Tags


Powered by WidgetsForFree

Archives