Friday, December 31, 2010

What is a Web Service?

A Web service is a software system identified by a URI whose public interfaces and bindings are defined and described using xml. Its definition can be discovered by other software systems. These systems may then interact with internet protocols.

(OR)

A Web service is a software application, accessible on the web through URL, that is accessed by clients using XML based protocols, such as SOAP(Simple Object access protocol) sent over accepted Internet protocols such as HTTP. Client access a web service application through ts interfaces and bindings, which are defined using XML artifacts sch as a WSDL (Web Service Definition Language) file.

Thursday, December 30, 2010

A Small Request to 2011 - from 2010

Dear 2011,

As you know that , today I am completing my life time, I am going to die on this day. So, I want to take the opportunity to share my experience with you while leaving.

I am very happy in welcoming you, but at the same time I am very sad because I am leaving today.

I have spent my 365 days with all the people with some happiness and  with some sorrows.Even I tried allot to be more successful, but it was not as such as expected. I have taken formers stomach with Jal and Lila cyclones and at the end i am leaving with more corrupted year in the last decade with 2G Spectrum. I have made more successful inventions in the science and technology but those became very small under the corruption. 

I request you to don't repeat my mistakes in your 365 days of life and I am intimating you to that don't leave the corrupted politicians.

I request you to the more inventions in technology and don't eat the farmers stomach. Don't allow the terrorists into the country and try to eradicate the terrorist politicians. I can say that be cool and calm for all the days and be helpful to the poor people all ways in your life.

I hope that you will become a best year in this century ... :)


Yours loving friend

Your's 2010




Saturday, November 27, 2010

Caching in hibernate

Caching is a Temporary memory or buffer which resides at client side and stores the results sent by server. When client generates same request for multiple number of times, the first request generated results will be stored in cache and this result will be used across the multiple requests. This reduces the round trips between the client and server. Since the result will be collected from cache that is available at client side.

Hibernate supports for 2 levels of cache:
  1. Level one cache
  2. Level two cache.
Level One Cache:   
Level 1 cache is inbuilt cache and it will be associated with hibernate session objects. Every session object of hibernate application contains one inbuilt level one cache.

Responsibilities of Level one cache:
a)      If select query executed for multiple no of times with in a session. Only one time query goes to database software gets the result, remaining all the times result will be gathered from cache.
b)      If one of POJO class object is modified for multiple no of times with in a transaction of session object, instead of sending update query for multiple number of times, all the changes done on the object will be kept tracked and only one update query will be generated reflecting all the changes at the end of the transaction.

The different ways to remove the level 1 cache from session
i)                    Session.flush()  --> Flushes level one cache content to db software
ii)                   Session.evict()  --> Remove the content of level 1 cache
iii)                 Session.close() --> closes level 1 cache, before that it calls session.flush()
A hibernate client application can have multiple level1 caches because a hibernate application can have multiple hibernate session objects.
The data stored in level1 cache, level2 cache will be in full synchronization with table rows.

Level-2 Cache:

It is a configurable cache (Not a built in cache). Third party vendors are supplying supporting jar files for level 2 cache. Level2 cache is global cache and it is visible for all the session objects of the hibernate application.
When level-2 cache is enabled the results gathered for database software will be stored in both level 1 and level 2 caches.
sessionFactory.close()  --> Destroys the session factory object and releases level 2 cache.
sessionFactory.evict(arga …)  --> Removes pojo class object from session factory.
sessionFactory.evictQueries(args…)  --> Cleans queries related data from cache. 

If hibernate use same request as second request or different session objects then software tries to collects the results either from leve1/level2 caches.
There are different third party providers for level 2 cache:
  1. Swarm Cache
  2. OS Cache,
  3. EH Cache
  4. JBoss Tree Cache … etc.

Friday, November 19, 2010

My Hero : Stephen Hawking

Heroes are the people who can overcome fear, or help others overcome fear. 
Here I am happy to tell about is, someone who just lives his life as he is. He has faced terrible problems and has become a great person of new scientific era.
So he is my Role Model, He is my Hero, He is my Inspiration….
He is Stephen Hawking… He is a unique person with extraordinary mind.
My Hero is a person whose greatness sneaked up on the world. He was born on 8th January 1942 in England. Although there were thousands of people born on that day, but he was special. As child he is little clumsy and bit too smart.
With his smartness he became great intellect but with his clumsiness he got the disease called “Motor Neuron Disease”. With this disease he has been confined to a wheel chair from the last 4 decades and most of his external body organs stopped working. From the last 25 years he is not able to speak.


Hacking’s external organs eyes, ears and little left hand small fingers only active. In spite of all these physical disabilities he is totally dedicated to his work. 
Actually Hawking has been working on basic laws of the Universe. Hawking has done many great things, I found fallowing are the major things according to me.
He has done the extreme work in new scientific era. He has been proved that the Black Holes emit the Radiation and now it’s named as Hacking’s radiation.
In 1988 he wrote a book called “A Brief History of Time” which became the international best seller of the year.
American news paper Chicago Times wrote “Hawking is a legend right up there with Galilee and Newton and Einstein”.
Here I will share one important thing about Hawking which happened in his life. Once he was in middle of writing a book. With his disease he lost his voice. There is no other way to write or communicate except by blinking of eyes. Fortunately, he loved his work so much that he continued on with it despite the ever clinking fear dying.
After several years he has received a present from his college friend. The present was a revolutionary new Computer that attached to his Wheel chair and would talk to him. He now had a way to write his papers and lectures to students. It seemed that his life was now seems better.
I hope that, generally our problems are not bigger than Hawking’s problems.
He has not saved someone’s life, but he inspired mine. So in my opinion, He is my Hero and if you don’t mind he will always be my hero.
Are our problems are bigger than Hawking’s problems? Never right…..
So, He is My Role model, He is my inspiration finally he is my HERO…

Thanks….

Wednesday, November 3, 2010

Connection Sql Server using Java

package com.javatutorials;

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

public class SqlServerConnection {
    public static Connection connection = null;
    public static Connection getDbConnection() {
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            connection = DriverManager
                    .getConnection("jdbc:odbc:mydsn;user=sa;password=sa12$");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return connection;
    }

    public static void closeConnection() {
        if (connection != null)
            try {
                connection.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
    }
}
mydsn in the above class is the dsn created to connect to sql server using jdbc-odbc connection.

The dsn  creating process can be found at : Create SQL Server dsn


Create Folder in Java Example

import java.io.File;
/**
 * @author mallikarjung
 *
 */
public class FolderCreation {
    public static String folderPath = "D:/SampleFolder/";
    /**
     * @param args
     */
    public static void main(String[] args) {
        File folder = new File(folderPath);
        //check whether folder exists or not
        if(!folder.exists()){
            folder.mkdir();
            System.out.println("Folder has been created Successfully ... ");
        }
    }
}

Replace String Example in Java

/**
 * @author Mallikarjun G
 *
 */
public class JavaStringReplaceExample {
    /**
     * @param args
     */
    public static void main(String args[]) {      
        String str = "Replace String";
        System.out.println(str.replace('R', 'A'));// Replaceing R with a in str
        System.out.println(str.replaceFirst("Re", "Ra"));// Replaceing First Re with Ra in str  
        System.out.println(str.replaceAll("Re", "Ra")); // Replaceing All Re with Ra in str   

    }


}

Monday, October 11, 2010

Difference between Struts and JSF

Struts is an Action framework and JSF is component framework.
Action Framework: Struts (both 1 and 2) are action frameworks. In essence they give you the ability to map URLs to activities and code on the back end. Here, the layout and workflow tends to be more page oriented. As a developer you tend to interact with the HTTP request cycle directly, though Struts 2 helps isolate at least the binding of the request data to the action implementation classes.
Action framework coders can have more control of the structure and presentation of URLs, since their systems are more intimately tied to them compared to a component framework.
Component Framework: In a component framework, artifacts that are rendered on the page are initially developed as individual components, much like in modern GUI "fat client" libraries. You have components, they have events, and your code is written to work with those events against the components. Most of the time, in mainstream development, your code is pretty much ignorant of the HTTP request cycle and processing.
JSF eliminated the need of Form Bean and DTO classes as it allows the use of same pojo class on all tiers of the application because of the Backing Bean.
In struts framework we can access the request and response objects directly, as in case of JSF we can access request and response objects indirectly.
Struts has a more sophisticated controller architecture than does JavaServer Faces technology. Struts is more sophisticated partly because the application developer can access the controller by creating an Action object that can integrate with the controller, whereas JavaServer Faces technology does not allow access to the controller.
In addition, the Struts controller can do things like access control on each Action based on user roles. This functionality is not provided by JavaServer Faces technology.
Struts frameworks is  better for "web sites", site like this one, sites that focus on delivering content to the user. Where it's mostly a "read only" experience for the end user who is likely to want to bookmark things, come back to arbitrarily deep pages, etc.
JSF framework is better for CRUD screens, back office applications, lots of forms and controls, etc. Here, the workflow is more controlled. You tend to not get to a "detail" screen with going through the "list" screen or "header" screen first, for example.
struts validate full beans (validator.xml) jsf has a pluggable validator-mechanism

Friday, October 1, 2010

Available implementations and Plugins of JSF?


JSF is the java specification given by the sun microsystems. For this specifications there are multiple;e implementations from the different third party vendors. 
The main implementations of JavaServer Faces are:
  1. Reference Implementation (RI) by Sun Micro systems.
  2. Apache MyFaces is an open source JavaServer Faces (JSF) implementation or run-time.
  3. ADF Faces is Oracle’s implementation for the JSF standard.

The main Pluginsof JavaServer Faces are: 
  1. Ice Faces FROM ICEsoft Technologies Inc.
  2. Prime Faces from Prime Technology.
  3. Rich Faces from JBoss
  4. Open Faces from TeamDevLtd
  5. DOJO Faces from DOJO 

Advantages of JSF

The major benefits of JavaServer Faces (JSF) technology are:
  1. JavaServer Faces architecture makes it easy for the developers to use. In JavaServer Faces technology, user interfaces can be created easily with its built-in UI component library, which handles most of the complexities of user interface management. 
  2. Offers a clean separation between behavior and presentation.
  3. Provides a rich architecture for managing component state, processing component data, validating user input, and handling events.
  4. Robust event handling mechanism.
  5. Events easily tied to server-side code.
  6. Render kit support for different clients
  7. Component-level control over statefulness
  8. Highly 'pluggable' - components, view handler, etc
  9. JSF also supports internationalization and accessibility
  10. Offers multiple, standardized vendor implementations

Wednesday, September 29, 2010

Oracle Database queries

To know the current user in Oracle
select user from dual;
Steps to know list of users in the Oracle database.
Connec to dba user
conn sys/password as sysdba;
execute below query to get list of users
select * from dba_users;
To select only user names:
select username from dba_users;
To know the full details about the user:
select * from dba_users where username='scott';
To get the Table space name:
select tablespace_name from dba_tablespaces;
To list the username and size of the user:
select owner,sum(bytes) from dba_segments group by owner;

Saturday, September 25, 2010

What is JSF?

JSF stands for Java Server Faces and it is an industry standard and a server side user interface component framework for building component-based user interfaces for web applications. JSF has set of pre-assembled User Interface (UI).
It is event-driven programming model. By that it means that JSF has all necessary code for event handling and component organization. Application programmers can concentrate on application logic rather sending effort on these issues. It has component model that enables third-party components to be added like AJAX.

Friday, September 17, 2010

My wonderful journey to "Shirdi"

My friends and I have a very great journey to Shirdi, which started on 30th July of 2010 and lasted for 2 days and I can say that, this tour is one of my great tours in my journey of life. So, I am very excited to share my experience with all of you......... :)

I appreciate all those persons who would spend some time to have a look at this.......

Our journey started on Friday at our office at 4 pm on the 30th July 2010, in an auto and we have reached the Secunderabad station nearly at 6.00 pm. It is cool. We had successfully got into the train on time with full anxiety in all the faces. We have a small breakfast before the journey started almost at 6.20 pm. Then our faces were glowing with happiness.

We started talking about our office after sometime we started playing dhum sharm arts which is most fun part of our journey, after playing almost for 2 hours we had our dinner, which we bought from the famous PARADISE restaurant in Secunderabad, after finishing dinner again we started playing dhum sharm arts almost up to 11, as it is a train journey the police were moving here and there and finally we had to stop playing as co-passengers started to sleep and finally we have reached Nagarsol by next day morning.

We all got our luggage and got down from the train and saw that almost full train got down at Nagarsol as it a Saturday. So we finally got out of station and saw all the buses were full and there is no bus available for us to go to shirdi. But there were many taxis and the hire fares are very high. So we couldn’t get into that taxis also. Almost all of the taxi drivers were from Hyderabad itself, finally another bus came so we all started to follow that bus, suddenly one of the taxi driver agreed to take us to Shirdi at lower fare which is almost at bus fare so we got into the taxi and this driver is also from Hyderabad.

Finally we got the taxi and asked him to take us to some lodge, but he said that he has lodge and rental fare is also reasonable, so we are ready to go to his place and decided to stay at his place as it was good and reasonable. After that we starting asking him want are all the places that we can see over there.

We have checked what all the places to cover are, after that we came to know that the harathy was going to be at 11:30 so we all started to get ready to go the temple. Finally we got ready to go to temple it was 9:30. After reaching temple we came to see that the temple is very crowded. We have stood in Darshan Q which took us almost one and half hour to reach SAI BABA. After Darshan we all were scattered up at the end and by the time I saw around, there were none of my friend beside me.

After that I was on my way to museum and other places, in the middle I met all others one by one. One after one came so finally we checked whether all came or not. Next everybody went to buy prasadam to relatives friends, after that we saw that its almost lunch time and everybody is hungry and so all of us decided to go to devastanam to have lunch. So we have started but everyone is tried to walk to devastanam as no one is wearing sandals suddenly we saw bus their which take people to devastanam for free. So we went to that bus but only few of them able to get into bus and other went there by walk. At last we all gathered at devastanam and were shocked to see the shirdi devastanam as it is really very big and the maintenance over there is too good similar to any five star Hotel, the food also tastes good and all that is for 10 rs only.

We all finished lunch and started to walked back to rooms which is about 2-3km and after walking for such long distance people still have energy to go to ShaniSinganapur. So finally we have talked to driver for a decent rental fare and got ready for journey.

The journey to Shanisingnapoor:

ShaniSinganapur  is one of the holiest places in Maharashtra. It is very famous for the lord Shani. The journey to ShaniSinganapur is nearly 2 hrs from Shirdi. While we are going to ShaniSinganapur, we have seen two to three places like Veerabadra Temple and other.
The above images are captured at Veerabadra Temple, Its looking like one of the good visiting place in Maharastra.

This image shows another Temple which we have visited while going to ShaniSinganapur.

I would like to discuss one interesting thing here. While we are going to ShaniSinganapur, there are number of Sugar cane juice shops beside the main road. We surprised by looking the preparation of Shugar cane juice with bulls and wooden gears. The juice was so tasty that we had drunk almost 20 glasses for the 9 people. We have enjoyed sometime there by spending on capturing photos and having the cane juice.

We thought that, if any person comes ShaniSinganapur tour, he should not miss to have the Sugar Cane Juice.

This image shows the preparation of Sugar cane Juice.

After Successful journey we have reached ShaniSinganapur at 6.30pm. Because that day was Saturday and it is a special day for Lord Shani, and the temple at ShaniSinganapur was packed with devotees. It is a custom there that only gents are allowed near the idol and that too only after taking a bath and with wet Dhotis provided there. There is a special queue for those who want to approach the idol, and this was quite long. We had darshan soon, and started on our return journey and we have reached Shirdi almost at 10.30 pm.
We had our dinner and we slept for the day.
Next day we planned to go for Nasik and Thrayambakeshwar and also Panchavati.
Due to our fixed plan we have got up at 7:00 AM and we completed the daily chores and we starts to go Nasik at 9.00 am. It was the long journey of 3 hours to reach Nasik. It was raining, cool and full crowd.
Nasik:
Nasik is one of the world's holiest Hindu cities. Known for its beautiful and picturesque surroundings, flourishing valleys, Nasik is home to many vineyards and orchards. Today, Nasik is rate as one of India's fastest growing cities. Nasik is known for its pleasant and cool climate, picturesque surroundings, high standard of living, greenery and well-developed infrastructure.


We had Darshan at 3.30 pm in Rama temple which we are seeing in image above. After completion of Darshan we started moving to Trimbakeshwar.

While going to Trimbakeshwar from Nasik, it was fully raining. All of our bags are sinking with rain water as we kept those on the top of our vehicle.
 It was fully green on the both sides of the road. It looks superb while we are crossing the mountains. The water falls are running with heavy water and look good.
We have tried to capture most of the seines by camera while we are traveling. As we are moving so fast in the qualis, we were unable to capture more things. At last we have captured some of the natural things.

The images shown here are the captured by us while we are moving to Trayambakeshwar..

Finally, after successful journey we have reached Trayambakeshwar at 4.00pm. It was fully raining, so we bought the covers for 10 rupees for each and we went to the temple.

From the long view of the Trayambakeshwar was  amazing with the surrounding water falls.
Trayambakeshwar:

Trimbakeshwar temple is a religious center having one of the twelve Jyotirlingas. The extraordinary feature of the Jyotirlinga located here is its three faces embodying Lord Brahma, Lord Vishnu and Lord Rudra. Due to excessive use of water, the linga has started to erode. It is said that this erosion symbolizes the eroding nature of human society. The Lingas at Trimbakeshwar are covered by a jeweled crown which is placed over the Gold Mask of Tridev (Brahma Vishnu Mahesh). The crown is said to be from the age of Pandavs and consists of diamonds, emeralds, and many precious stones. The crown is displayed every Monday from 4-5 pm (Shiva).All other Jyotirlingas have Shiva as the main deity. The entire black stone temple is known for its appealing architecture and sculpture and is at the foothills of a mountain called Brahmagiri.Three sources of the godavari originate from the brahmagiri mountain.

It has taken 1 1/2 hour to come from darshan in temple. After completion of Darshan, we started to coming Panchavati. We had lunch in Andra mess, its on the way to Trimbakeshwar to Panchavati. We have reached the panchavati at 6.30 pm.

Panchavati:

In Panchavati, there are five trees marked, one of which is an Ashoka tree. There is also a cave here called Sita Guha. Sita, Ram and Lakshman prayed here to Lord Shiva. The ancient Shivalinga still exists in the small temple in the cave and is visited by devotees. Today this area is a major pilgrimage and tourist attraction.
Panchavati is one of the coolest and cleanest areas of Nasik. It has got many temples like Kalaram Madir, Goraram Mandir, Sita Gupha. There are many temples in Tapovan which is very close to Panchavati and can be considered to be in Panchavati.

People of Panchavati are soft-spoken. They are proud of the culture and of five thousand year old tradition.

The image shows the Triveni Sangamam located in the Panchavati. The two rivers Aruna and Varuna comes from underground and combines with the river Godavari. At this place Kumbamela is celebrated for every 12 years. Most of the devotes come to this place on the days of Kumbamela. According to Hindu mythology, it is believed to be the place where a few drops of 'amrut' fell while the kalash was carried to the devatas.

From Panchavti we directly came to Railway station at 8.30 pm and we have caught the train on time. We played Dhum Sharam arts again in the train and we also recollected the memorable movement which we have in the tour. We enjoyed a lot. We have reached the Secunderabad railway station at 8.30 am and as usually we came to office on Monday

In Conclusion, I would like to say that, we have a great journey experience and we had lot of enjoyment in this tour. I wish to have such a great experience to all, who goes to Shirdi.

Thanks to all .....................

Friday, August 27, 2010

Phone Calls through GMail at lower rates

Are you using the Gmail voice and vedio chat to communicate your dear ones. Yes? its good... Now you can communicate your dear ones when they are not before the computer. How? Its simply with "Google Net Talk".
Wouldn’t it be nice if you could call people directly on their phones using Gmail?
Lets start thinking about Google Net talk...
Google’s Gmail, the one of the largest e-mail site with millions of users worldwide. Recently, Google introduced the calling of landlines and mobiles phones using Gmail. So, from now you can call to your dear ones using the Gmail and u can enjoy the talking with them at lower rates.
In their blog they are telling about rates as "Calls to the U.S. and Canada will be free for at least the rest of the year and calls to other countries will be billed at our very low rates. We worked hard to make these rates really cheap (see comparison table) with calls to the U.K., France, Germany, China, Japan—and many more countries—for as little as $0.02 per minute".

Comparison of rates are looks like this.
You can find the more details about call rates in the fallowing link https://www.google.com/voice/rates



How to use it?
Google said making a call through its service works like a normal phone in that a user could click on the "call phone" option in their chat buddy list in Gmail and type in the number or enter a contact's name.
If you have a Google Voice phone number, calls made from Gmail will display this number as the outbound caller ID. And if you decide to, you can receive calls made to this number right inside Gmail.



Can I use this now?
If you are from U.S. you can, but you shold have the installtion of voice and vedio plugin if you haven't already.
The Google people are saying that " We’re rolling out this feature to U.S. based Gmail users over the next few days, so you’ll be ready to get started once "Call Phones" shows up in your chat list. If you’re not a U.S. based user—or if you’re using Google Apps for your school or business—then you won't see it quite yet. We’re working on making this available".

What can we expect?
You can make the calls from Gmail using your computer only, you cannot call to a user by using Gmail in your mobile phone. Mobile version of Call Phones is not yet launched.
The service given by the Gmail might increase the popularity of Gmail, which might be the insipiration for the other emails stakes like yahoo and MSN to implement such a high level functionalities in the mails.

Conclusion:
In these days calling is so cheap from the prepaid and postpaid mobile services and other cell phone services. This might cause the less usage of Google Call Phone for domestic calls, but definately it might have great demand for the International Calls.
So, We have to wait until the google provides this Call Phone throught the world and see the
Calling is so cheap already that I don't think it will attract a huge amount of domestic calling. It could take some of the international market.


Inputs from:



Thursday, August 19, 2010

Enabling JMX remote port in WEBLOGIC

Weblogic runs with domains. With different domains you can enable the JMX port by fallowing the below steps.

Step 1: Go to your domain bin folder, which you want to enable JMX remote port.
Ex: C:\bea\wlserver_10.3\samples\domains\wl_server\bin

Step 2: edit the “setDomainEnv.cmd” file and add the fallowing code as above line of the set CLASSPATH
set JAVA_OPTIONS= %JAVA_OPTIONS%
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8006
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
Step 3: Restart the weblogic server.

Step 4 : Try to connect for the Jconsole with host:8006, It will connect to your domain of weblogic server.

Fetch All the Records From Cassandra database exmaple

package com.examples;

import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import org.apache.cassandra.thrift.Cassandra;
import org.apache.cassandra.thrift.Column;
import org.apache.cassandra.thrift.ColumnOrSuperColumn;
import org.apache.cassandra.thrift.ColumnParent;
import org.apache.cassandra.thrift.ConsistencyLevel;
import org.apache.cassandra.thrift.InvalidRequestException;
import org.apache.cassandra.thrift.KeyRange;
import org.apache.cassandra.thrift.KeySlice;
import org.apache.cassandra.thrift.NotFoundException;
import org.apache.cassandra.thrift.SlicePredicate;
import org.apache.cassandra.thrift.SliceRange;
import org.apache.cassandra.thrift.TimedOutException;
import org.apache.cassandra.thrift.UnavailableException;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;


public class CassandraFeatchHInfo {
    public static final String UTF8 = "UTF8";

    public static void main(String[] args) throws UnsupportedEncodingException,
            InvalidRequestException, UnavailableException, TimedOutException,
            TException, NotFoundException {
       
        TTransport tr = new TSocket("192.168.1.204", 9160);
        TProtocol proto = new TBinaryProtocol(tr);
        Cassandra.Client client = new Cassandra.Client(proto);
       
        tr.open();
       
        String keyspace = "Historical_Info";
        String columnFamily = "Historical_Info_Column";
        //String keyUserID = "3";
         
       

        // read entire row
        SlicePredicate predicate = new SlicePredicate();
        SliceRange sliceRange = new SliceRange();
        sliceRange.setStart(new byte[0]);
        sliceRange.setFinish(new byte[0]);
        predicate.setSlice_range(sliceRange);
       
       
        KeyRange keyrRange = new KeyRange();
        keyrRange.setStart_key("1");
        keyrRange.setEnd_key("");
        //keyrRange.setCount(100);
       

        ColumnParent parent = new ColumnParent(columnFamily);
       
        List ls = client.get_range_slices(keyspace, parent, predicate, keyrRange, ConsistencyLevel.ONE);
       
        for (KeySlice result : ls) {
            List column = result.columns;
            for (ColumnOrSuperColumn result2 : column) {
                Column column2 = result2.column;
                System.out.println(new String(column2.name, UTF8) + " ->  " + new String(column2.value, UTF8));
            }
        }
       
       
        tr.close();
    }
}

Cassandra Fetch Example -- Single Row fetch

package com.examples;

import java.io.UnsupportedEncodingException;
import java.util.Date;

import org.apache.cassandra.thrift.Cassandra;
import org.apache.cassandra.thrift.Column;
import org.apache.cassandra.thrift.ColumnPath;
import org.apache.cassandra.thrift.ConsistencyLevel;
import org.apache.cassandra.thrift.InvalidRequestException;
import org.apache.cassandra.thrift.NotFoundException;
import org.apache.cassandra.thrift.TimedOutException;
import org.apache.cassandra.thrift.UnavailableException;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;

public class CassandraFetchHInfo {
    public static final String UTF8 = "UTF8";

    private static Long hiId = new Long(1) ;
   

    public static void main(String[] args) throws UnsupportedEncodingException,
            InvalidRequestException, UnavailableException, TimedOutException,
            TException, NotFoundException {
      
        CassandraFetchHInfo cassandraFetchHInfo = new CassandraFetchHInfo();
        cassandraFetchHInfo.insertHistoricalInfo(hiId, objectObjHierarchyId, hiParameterOid, hiMonitoredValue, hiTimestampCreated, hiObjectId, hiInfoEventType);
    }

    public void insertHistoricalInfo(Long hiId,
            Long objectObjHierarchyId, String hiParameterOid,
            String hiMonitoredValue, Date hiTimestampCreated,
            Object hiObjectId, String hiInfoEventType) {
        System.out.println("Stating of class................................");

        try {

            TTransport tr = new TSocket("localhost", 9160);
            TProtocol proto = new TBinaryProtocol(tr);
            Cassandra.Client client = new Cassandra.Client(proto);
            tr.open();

            String keyspace = "Historical_Info";
            String columnFamily = "Historical_Info_Column";

            String keyUserID = hiId.toString();

          
            ColumnPath colPathhiId = new ColumnPath(columnFamily);
            colPathhiId.setColumn("hiId".getBytes(UTF8));

          
            // read single column
          
             System.out.println("single column:");
             Column col = client.get(keyspace, keyUserID, colPathhiId, ConsistencyLevel.ONE).getColumn();
            
             System.out.println("column name: " + new String(col.name, UTF8));
             System.out.println("column value: " + new String(col.value, UTF8));
             System.out.println("column timestamp: " + new Date(col.timestamp));
            
            tr.close();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (InvalidRequestException e) {
            e.printStackTrace();
        } catch (TTransportException e) {
            e.printStackTrace();
        } catch (UnavailableException e) {
            e.printStackTrace();
        } catch (TimedOutException e) {
            e.printStackTrace();
        } catch (TException e) {
            e.printStackTrace();
        } catch (NotFoundException e) {
            e.printStackTrace();
        }
    }
}

Cassandra insertion example

package com.example;

import java.io.UnsupportedEncodingException;
import java.util.Date;

import org.apache.cassandra.thrift.Cassandra;
import org.apache.cassandra.thrift.Column;
import org.apache.cassandra.thrift.ColumnPath;
import org.apache.cassandra.thrift.ConsistencyLevel;
import org.apache.cassandra.thrift.InvalidRequestException;
import org.apache.cassandra.thrift.NotFoundException;
import org.apache.cassandra.thrift.TimedOutException;
import org.apache.cassandra.thrift.UnavailableException;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;

public class CassandraInsertExample {
    public static final String UTF8 = "UTF8";

    private static Long hiId = new Long(1) ;
   
    public static void main(String[] args) throws UnsupportedEncodingException,
            InvalidRequestException, UnavailableException, TimedOutException,
            TException, NotFoundException {
       
        CassandraInsertExample cassandraInsertHInfo = new CassandraInsertExample();
        cassandraInsertHInfo.insertHistoricalInfo(hiId);
    }

    public void insertHistoricalInfo(Long hiId) {
        System.out.println("Stating of class................................");
        try {
           
            TTransport tr = new TSocket("localhost", 9160);
            TProtocol proto = new TBinaryProtocol(tr);
            Cassandra.Client client = new Cassandra.Client(proto);
            tr.open();

            String keyspace = "Employee";
            String columnFamily = "Employee_Details";

            String keyUserID = hiId.toString();

            // insert data
            long timestamp = System.currentTimeMillis();

            ColumnPath colPathhiId = new ColumnPath(columnFamily);
            colPathhiId.setColumn("hiId".getBytes(UTF8));
            client.insert(keyspace, keyUserID, colPathhiId, hiId.toString().getBytes(UTF8), timestamp, ConsistencyLevel.ONE);
           
             //Fetching of single row
             Column col = client.get(keyspace, keyUserID, colPathhiId, ConsistencyLevel.ONE).getColumn();
           
             System.out.println("column name: " + new String(col.name, UTF8));
             System.out.println("column value: " + new String(col.value, UTF8));
             System.out.println("column timestamp: " + new Date(col.timestamp));
           
            tr.close();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (InvalidRequestException e) {
            e.printStackTrace();
        } catch (TTransportException e) {
            e.printStackTrace();
        } catch (UnavailableException e) {
            e.printStackTrace();
        } catch (TimedOutException e) {
            e.printStackTrace();
        } catch (TException e) {
            e.printStackTrace();
        } catch (NotFoundException e) {
            e.printStackTrace();
        }
    }
}