King Parikshit was the son of Abhimanyu and the grandson of Arjuna. Once, while hunting in a forest, he pierced a deer with his arrow. The wounded deer ran away. Parikshit went in search of the deer. He walked a long distance in the forest but could not find the deer. Fatigued and thirsty, he came across Sage Samika seated in a cow-pen and drinking the froth oozing out of the mouths of calves after they had fed themselves of the cows. He asked the sage, “Oh saint, I am King Parikshit, son of Abhimanyu. A deer pierced by me has been lost. Did you see it?'
Since the sage was observing a vow of silence, he didn’t rely. Angered by the sage’s silence, Parikshit picked up a dead snake with the end of his bow and placed it on the sage’s shoulder. Even then, the sage didn’t react and suffered the insult silently.
Finding that the sage didn’t protest at the treatment meted out to him, Parikshit felt sorry for his act and returned to his palace quietly. Sage Samika had a son by name Sringin who had gone out. He had great energy and observed severe austerities. He was severe in his vows, very wrathful, and difficult to be appeased. One of his friends told him that King Parikshit had insulted his father by placing a dead snake on his shoulder.
Sringin became very angry on hearing this and cursed Parikshit to be bitten within seven days, by Thakshaka, the King of snakes. After throwing this curse, Sringin went to his father and found him sitting with the dead snake on his shoulder. He told his father that he had cursed Parikshit.
The sage chided his son saying, “I am not happy about what you have done. Ascetics should observe restraint. We live in the country ruled by King Parikshit and we are protected by him. If he didn’t protect us, we wouldn’t be able to perform the penances peacefully. Parikshit was tired and thirsty when he came here. He was not aware of my vow of silence and had acted in haste. We should have forgiven him.. The king protects the sacrificial rites and these rites please the gods who give us rains which help the plants and trees that provide food to us grow. A country without a king will suffer. You have acted rashly and immaturely.”
Sirgin relied, “Whether what I have done is right or not, the words I have uttered will come true and a curse can never be revoked.”
Sage Samika sent one of his disciples named Gurumukha to King Parikshit for apprising the king of the curse. Gurumukha went to the palace met the king and apprised him of the developments. Parikshit grieved not so much about the curse as about the fact that he had insulted the great sage without being aware of his vow of silence.
Parikshit then consulted his ministers and as per their advice, had a mansion erected on a solitary column. The mansion was closely protected by guards and no one could enter the palace unseen. Brahmins sitting in the mansion were engaged in chanting mantras continuously.
Thakshaka devised a deception to enter the mansion. He made some snakes take the form of ascetics and enter the palace with gifts of fruits for the king. Thakshka took the form of a small insect and penetrated one of the fruits. The snakes accordingly disguised themselves as ascetics, entered the mansion and met the king . The unsuspecting king accepted the gifts offered to him. After the ‘ascetics’ had left, King Parikshit, along with his ministers began to eat the fruits. As fate would have it, the fruit in which Thakshaka was hiding came to be eaten by the king. Parikshit observed a small insect coming out of the fruit and took it in his hand.
He told his ministers, “The sun is about to set. The deadline for the curse is about to end. Let this insect become Thakshaka and bite me so that my sin will be expiated by the words of the sage coming true.” This was seconded by all the wise men assembled there.
King Parkikshit placed the insect on his neck. Even as the King was smiling, Thakshaka assuming his real form coiled around the king's neck and bit him causing him to die instantly. The entire mansion blazed with the fire of Thakshaka’s poison making all the ministers flee the scene. They saw Thakshaka coursing through the sky.
You can read this story in more detail here:
The councillors of Parikshit had his last rites performed and crowned his eldest son Janamejaya the king. Janamejaya was only a boy at that time. After sometime his ministers, intending to provide a strong support to the young monarch approached Suvarnavarman, the King of Kasi and asked him to give his daughter Vapushtama in marriage to Janamejaya. The king acceted the proposal and got his daughter Vapushtama married to Janamejaya. After the marriage, Janamejaya travelled to many places along with his wife, enjoying life in the company of his wife.
After sometime, Janamejaya asked his ministers about his father and his achievements. The ministers told him what a great virtuous and compassionate ruler Parikshit was. Then he asked them about the cause of his father’s death. They told him all the details including Thakshaka’s persuading Kasyapa to go back by giving him the wealth he wanted to get from the king.
Janamejaya asked them how they came to know of what transpired between Thakshaka and Kasyapa, they said that this was revealed by a person who was sitting on a dry branch of a banyan tree with the intention of cutting some wood to be used as a sacrificial fuel. He had overheard their conversation. He was also burnt to ashes when the tree was bitten by Thakshaka but was subsequently revived when Kasyapa brought the tree back to life.
On learning that his father was bitten by the serpent Thakshka using deception, Janamejaya decided to avenge the death of his father. His anger was directed at Thakshaka for having prevented Kasyapa from coming to the palace and bringing the king back to life after he was bitten by Thakshaka. He felt that Thakshaka should have done this because he would have become an object of ridicule if the king was brought back to life by Kasyapa after he was bitten by Thakshaka.
Janamejaya was also prodded by Utanka to avenge his father’s death. He called the chief priest of his country and expressed his intention to burn Thakshaka and other snakes who had burnt his father through his poison. The priest told him that there was a sacrificial ritual called Sarpa Yaga through which the snakes could be offered to Agni, the God of Fire. The king ordered that arrangements be made to perform such a sacrifice by engaging the services of Brahmins well versed in the rites.
The Snake Sacrifice was performed following due procedure, Many snakes were drawn to the sacrificial fire by the power of the mantras chanted by the Rishis (sages) and were burnt to ashes. However, Thakshka himself was saved by the intervention of sage Astika who sought and got a boon from Janamejaya that Thakshaka would be spared.
Sage Vyasa himself attended the sacrifice. Janamejaya requested him to narrate the story of his ancestors, the Pandavas, which Vyasa had already recorded in the form of the epic, later came to be known as Mahabharata. Vyasa asked his disciple Vysampayana to narrate the story.
This is how Mahabharata was narrated before an audience for the first time. One of those who listened to this discourse, Sage Ugrasrava, subsequently narrated the story to a group of sages who were doing penance in the forest of Namisaranyam.
You can read the incidents relating to Janamejaya's sacrifice at the following links: