Sunday, December 16, 2012

C3P0 connection pool configuration Spring Hibernate

Recently I faced an error with our server, every morning we received an 500 error as follow:

HTTP Status 500 - Request processing failed; nested exception is org.springframework.dao.DataAccessResourceFailureException: could not execute query;

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 54,840,265 milliseconds ago. The last packet sent successfully to the server was 54,840,266 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.

 For a while I was browsing and searching in google to solve this issue, and then I figured out what I need, a connection pool, so I started to configure our Java projects with C3P0 (see for completing info).

First step: You should add the c3p0 dependency to your pom.xml


Second step: Set dataSource configuration to some like this:

<bean class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close" id="dataSource">
<property name="driverClass" value="${jdbc.driverClassName}">
<property name="jdbcUrl" value="${jdbc.url}">
<property name="user" value="${jdbc.username}">
<property name="password" value="${jdbc.password}">

<!-- C3P0 properties -->
<property name="minPoolSize" value="${hibernate.c3p0.min_size}">
<property name="maxPoolSize" value="${hibernate.c3p0.max_size}">
<property name="maxIdleTime" value="${hibernate.c3p0.idle_test_period}">

<bean class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" id="sessionFactory">
<property name="dataSource" ref="dataSource">
<property name="annotatedClasses">
<property name="hibernateProperties">
        <prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="">${}</prop>
<prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
<prop key="hibernate.show_comments">${hibernate.show_comments}</prop>

Third step: Add this to your pom.xml

<jdbc .driverclassname=".driverclassname">com.mysql.jdbc.Driver</jdbc>
<jdbc .url=".url">jdbc:mysql://localhost:3306/vapaya</jdbc>
<jdbc .username=".username">vapayaUser</jdbc>
<jdbc .password=".password">v4p4y4DB</jdbc>

<hibernate .dialect=".dialect">org.hibernate.dialect.MySQLDialect</hibernate>
<hibernate .cache.provider_class=".cache.provider_class">org.hibernate.cache.NoCacheProvider</hibernate>
<hibernate .show_sql=".show_sql">true</hibernate>
<hibernate .format_sql=".format_sql">false</hibernate>
<hibernate .show_comments=".show_comments">true</hibernate>

<hibernate .c3p0.min_size=".c3p0.min_size">5</hibernate>
<hibernate .c3p0.max_size=".c3p0.max_size">20</hibernate>
<hibernate .c3p0.idle_test_period=".c3p0.idle_test_period">3000</hibernate>

Fourth step: Add this to your properties file




That's all, in order to know is everything is set, you should see this output in catalina.out:

Dec 16, 2012 5:35:17 PM com.mchange.v2.c3p0.C3P0Registry banner
INFO: Initializing c3p0- [built 21-May-2007 15:04:56; debug? true; trace: 10]

Some additional information about if it's working is as follow:

1. Connect to mysql, command line.
2. type: show processlist;

This should show you 5 connections (minimum pool size).

I hope you find this helpful.

Monday, December 10, 2012


I refused to end this year without another mix, this one has some favorite dj such as Deadmau5 and Daniel Kandi, includes also a delicious track called Revolution by Rowald Steyn. This sound  mix goes from Progressive House to Uplifting Trance.


1. Deadmau5 - HR 8938 Cephei (Original Mix) (10:48)
2. Electrocker - Enfoire (Original Mix) (6:9)
3. Dominik Eulberg - Bionik (Orginal Edit) (8:32)
4. Solarity - Marsh (Original Mix) (8:18)
5. Deadmau5 - Faxing Berlin (Chris Lake Edit) (8:13)
6. Rowald Steyn - Revolution (6:24)
7. Phillip Alpha & Daniel Kandi - Sticks & Stones (Beat Service Remix) (7:37)
8. Miguel Bose - Por ti (Above & beyond remix) (8:31)

I hope you like it.

Friday, July 06, 2012

Shortcut to switch language keyboard in Ubuntu

Step1. Select Keyboard Layout from applications

Step 2. Click on Options button and select your keys combination from Keys to change layout options

Step 3. Enjoy

Sunday, May 27, 2012

Speaking in public

A speech is the act of expressing or describing thoughts, feelings, or perceptions with words in public. There are four different types of speeches that can be given.

* Informative   This is designed to explain, instruct, or clarify
* Persuasive    This influences, motivates to act, or sells.
* Inspirational This inspires or helps the listeners to celebrate or commemorate.
* Improvisational This is given without prior preparation.

Brainstorming and clustering

This is a way to organize your ideas easily, when brainstorming you focus on the topic and write down a list of any words, thoughts, or phrases that come to mind regarding that topic. Not every idea will be used in your speech, but the list will help in develop it.

Another way to gather ideas is by using method called clustering. It is a conceptual map helping to develop a variety of alternatives for the speech. Begin with the main topic in the center. As ideas come, extend a line from the central topic outward to the new ideas. Continue doing so as the ideas come. This process nowadays is also known as mind map.

Parts of speech


The role of the introduction is to capture the audience’s attention and introduce the general theme. This can be accomplished by any of the following methods.

* Ask rhetorical questions. This will cause the audience to begin thinking about the topic.
* Surprising statistics.
* Use a quotation. Remember to give credit where credit is due.
* Graphic description. This will draw a picture in the minds of those in the audience.


The body is where your principal and subordinate points will be expressed. It is important that your ideas are expressed as clearly as possible to avoid confusion. Divide the body into from three to five principal points, each one having one or more subordinate points and supporting  material. Supporting material can be testimonials, analogies, statistics and stories. These give the audience reason to believe your principal ideas.


The conclusion should summarize the principal ideas given in the body. It should also reinforce the points you want the listeners remember. Do not spend too much time concluding the speech.

This was based on Quick Learning Personal Development Workshop.

I hope you find this helpful.

Thursday, May 24, 2012

Napoleon Dynamite

Recently I saw Napoleon Dynamite an independent film directed by Jared Jess and starred by Jon Heder and Tina Majorino, the movie has a social satire context developed in a high school at Idaho United States. While the story isn't very complicated it still manages to appeal to adults and teens alike.


Stereotypes about mexican people are expressed in the move using Pedro, such as accent, clothes, style of life, believes. Let’s extend some info about it. Who is the santo niño de atocha which Pedro mentioned in his speech? In the 13th century Madrid was lost to the Muslim invaders, and many Christians there were taken prisoners as spoils of war. The Christians were placed on strict punishments and prohibitions, and the devout prisoners were denied food by their captors. According to legend, only children under the age of 12 were permitted to bring them food.Reports soon began among the people that a child under the age of twelve had begun to bring food to childless prisoners. The child was dressed in pilgrim's clothing yet could not be identified as to the name of the child or its origin. In fact  the santo niño de atocha is a Roman Catholic image of the Child Jesus. In Mexico therefore some people have an image of Santo niño de atocha in their houses as a pray to Jesus to avoid lack of food or basic goods for their families.

The piñata story

Summer and Pedro were competing to the president position at their school. Summer a cheerleader was working in gain votes using flyers and ads to his classmates meanwhile Pedro made a Pinata which in fact was looking like Summer. In the history original piñata was represented by a star shape and seven pikes “The Seven Deadly Sins” and colored with shining colors representing  yearn. Nowadays piñata makers found that they can sell more piñatas if they made them look like cartoon characters, it is not common in Mexico find piñatas looking like real people, only in those cases when piñata makers want to make a mock or offence to someone they do it.

What I loved most was the musical selection like Canned heat by Jamiroquai and The Promise by When In Rome, my favorite part of the movie: when Napoleon danced as skit of Pedro Sanchez, I enjoyed when Napoleon exhales in response about something disgusting and expressions  like “sweet”, “such an idiot!”, “geez!”, “fine!” and “I caught you a delicious bass”.

I’m yearning to see another movie like this, not only because it had not too much money spent in locations, stage, dressing, etc. but also because it is a good story and terrific music. By the way my most viewed video in youtube is “Napoleon Dynamite dance scene”. (636, 522 views and counting).

Enjoy it.

Friday, May 04, 2012

How to backup your favorite movies & TV shows

How do you could get a copy of your favorite video media? If your medias are in a DVD disc then you may ripping first, an easy cheaper option is Clone DVD Mobile and easy DVD. The last one is to access to the protected DVD information, the first one is to ripping properly. I always use the iPod video format since has good quality in audio and video and a reasonable size.

My suggestion: ripping only in English as language and if you want subtitles, you should search them in google such as as soon as you get the subtitle you can  add them using VLC. Video > Subtitles Track > Open File. Some times there is a desynchronize rate in subtitles and audio if so, you can synchronize using  Tools > Track Synchronization.

The storage rate is cheaper than other media format, for example you could store The Tudors first season in only two DVD (10 episodes 60 minutes each one as average).

Enjoy it.

Sunday, April 29, 2012

I Begin to Wonder

I Begin to Wonder born as a stubborn idea to integrate a Jean Claude Ades song mixed by Jerome Isma-ae, since past year I was trying to added and finally is here, becoming title for this the very first remix of this year. It's genre goes from Deep House, Tech House, Minimal House to Progressive House.

1. Rodrigo Carreira - Communicate (7:35)
2. Anthony Collins - Pop Off (Ludovic Vendi Dub Mix) (9:30)
3. Leron vs. Yves Eaux vs. Luke Star - You Will Be Mine (9:6)
4. EDX - Embrace (Original Club Mix) (7:13)
5. Boom Jinx And Andrew Bayer - Keyboard Cowboys (Original Mix) (7:37)
6. Matt Lange - Other Stories (7:52)
7. Ida Engberg - Owl's Nest (Original Mix) (7:58)
8. Jean Claude Ades - I Begin To Wonder 2008 (Jerome Isma-ae Remix) (9:0)

I hope you like it.

Friday, April 27, 2012

A glance to Ubuntu 12.04 Precise Pangolin

Today I updated my Ubuntu to the new Ubuntu 12.04 LTS "Precise Pangolin", The most immediately noticeable will be the new log in screen and better colors in all UI environment.  Ubuntu 12.04 has cooler tool tips when Rhythmbox change songs or in the launcher bar, also has HUD the new search-based menu and is really cool, since it can interact with all your installed programs such as Firefox (Exploring Bookmark / History), Skype (Filter online, offline contacts) or sending email with Thunderbird just typing email. You save time avoiding access nested menus in huge option programs like Gimp.

See here for more info

Perhaps the most welcome change, though, is the vastly improved performance and power management. Ubuntu, for all of its finer points, has never been particularly battery friendly.

The bad thing I found about it is the launcher side bar, which is quite intrusive in my perspective, I normally use an extended display monitor and now in this Ubuntu version I have to bear this launcher in my extended monitor as well.

After give a glance in the advantages and disadvantages I had no doubt to install it and start to use it, hope this info was useful to you.

Enjoy it.

Tres buenos libros de historia de México

México bárbaro de John Kenneth Turner

Es un ensayo escrito en 1908, dedicado a dar a conocer en los Estados Unidos los acontecimientos que se daban en México en aquella época, describiendo la esclavitud humana que se practicaba durante el gobierno de Porfirio Díaz en lugares como Yucatán y Valle Nacional.

La primera edición de este reportaje a profundidad, vio la luz en forma de libro en los Estados Unidos de Norteamérica en 1911. Se han hecho varias ediciones de la publicación tanto en México como en EE. UU. y se le considera como una importante contribución a la descripción de las condiciones sociales que existían en el México prerrevolucionario del Porfiriato.

Zapata de Pedro Ángel Palou García

Palou detalla: “Zapata luchó y tomó ciudades, llegó a la ciudad de México y estuvo a punto de tomar el poder, pero fue congruente con su convicción de que la política no es para los hombres del campo. Él le rehuyó al poder, nunca se sentó en la silla presidencial, de ahí que sólo buscaba acabar con las injusticias y hacer que se cumpliera la ley.

“Zapata nunca asumió un sólo puesto en la Convención de Aguascalientes, ni le aceptó ninguno a Francisco I. Madero. Fue un hombre de gran coherencia”.

Zapata tuvo que enfrentar muchos openentes en su lucha por defender sus ideales, entre ellos Porfirio Díaz, Francisco I. Madero, Alvaro Obregón y Venustiano Carranza, finalmente fue asesinado en la Hacienda de Chinameca en una trampa ejecutada por Jesús Guajardo.

Azteca de Gary Jennings

Hacia 1530, el emperador Carlos pide al obispo de México que le proporcione información sobre la vida y costumbres de los indios americanos; el obispo, fray Juan de Zumárraga, envía al monarca un relato autobiográfico hecho por un indio de unos sesenta años, Nube Oscura o Mixtli, en el que narra su niñez, la mentalidad y costumbres de su pueblo, su formación y sus amores, siempre tormentosos y trágicos. Por fin, el emisario de Moctezuma entra en contacto con los españoles de Hernán Cortés, es bautizado y recibe el nombre de Juan Damasceno, aunque sigue fiel a los usos de los aztecas. Ésta en su trepediante y desgarrada historia, que simboliza el choque de dos civilizaciones, de dos maneras irreconciliables de entender el mundo.

Thursday, April 19, 2012

Older people are happier

Feelings like stress, worry, anger decrease with age. In the paradox of ageing is mention that when we recognize we won't live forever change our perspective on life in positive ways, we recognize we don't own all the time in the world and we see our priorities most clearly, we take less notice of trivial matters we save or life, we are more appreciative, more open to reconciliation, we invest in more important things, and life gets better.

Laura Carstensen

Saturday, April 14, 2012

An efficient way to backup your information

Unison allows you to synchronize a directory with an external drive or a remote host, it is like mirroring your directory.

I would like to explain only external device option.

First connect your external device

Then run Unison and create a new profile where simply specify the paths to the directories you want to keep in sync.

The synchronization is pretty straightforward, in Unison screen you will see changes are ready to apply, finally select Go from the menu.

In my case, I'm always listening new music from several genres, and when some new track please me, I copied to /media/Shared/Music directory in a corespondent directory-genre name. Since I have a bunch of new tracks in different directories. Unison helps me to copy to my backup only new tracks, in a kind of incremental backup.


Friday, April 13, 2012

How to convert flac to mp3 usgin ffmpeg in ubuntu

In order to convert flac to mp3 you need to install ffmpeg in your computer.

As a root:
1. apt-get install ffmpeg
2. apt-get install lame
3. apt-get install libavcodec-extra-53

Then run command as follow:

ffmpeg -i audio_souce.flac -ab 256k audio_output.mp3

Where ab is bitrate in kb/s


Thursday, January 26, 2012

How to Create a Wallpaper Slideshow in Ubuntu 11.10

sudo add-apt-repository ppa:crebs/ppa
sudo apt-get update
sudo apt-get install crebs

Select your photos and name your slideshow.

After creating it. Crebs store it as xml file in $HOME/.crebs
Then rename & replace crebs xml file to background-1.xml in the path /usr/share/backgrounds/contest
Right mouse click on Desktop and select: Change Desktop background
Select your slideshow in the appearance window.

If for some reason the crebs repo doesn't work, you can always edit your /usr/share/backgrounds/contest/background-1.xml and change the images path for those which you want to use.

Don't forget to assign proper rights to the xml file. I use to set 666 with chmod command. (chmod 666 background-1.xml)

Enjoy it

Thursday, January 19, 2012


Have you ever needed to increment audio volume level from any of your videos? ok, it is not too common but anyway, there is a powerful tool to help us whit that task. FFmpeg, so I'm going to set the steps here.

1. Remove sound from a video file.

 ffmpeg -i source_video.ogv -an -vcodec mpeg4 -b 1200k just_video.mp4

2. Extract audio from video.

ffmpeg -i source_video.ogv -ab 128k just_audio.mp3

3. Increment volume from an mp3 audio

ffmpeg -i just_audio.mp3 -vol 2000 -ab 128k overninethousand_audio.mp3

4. Encode to the final video.

ffmpeg -i overninethousand_audio.mp3 -i just_video.mp4 -vcodec mpeg4 -b 1200k final_video.mp4

That's it, you have a new video with over nine thousand level.

FFmpeg site