Insert UTF-8 in postgreSQL using hibernate
<p>I am trying to insert UTF-8 in database using hibernate and spring.</p>

<pre><code> &lt;?xml version='1.0' encoding='utf-8'?&gt;
 &lt;!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;

&lt;hibernate-configuration&gt;

&lt;session-factory&gt;



    &lt;property name="hibernate.connection.CharSet"&gt;utf8&lt;/property&gt;
    &lt;property name="hibernate.connection.characterEncoding"&gt;utf8&lt;/property&gt;
    &lt;property name="hibernate.connection.useUnicode"&gt;true&lt;/property&gt;

    &lt;!-- Database connection settings --&gt;
    &lt;property name="connection.driver_class"&gt;
        org.postgresql.Driver
    &lt;/property&gt;
    &lt;property name="connection.url"&gt;
        jdbc:postgresql://192.168.6.51:5432/JayHind?UseUnicode=true&amp;amp;characterEncoding=utf-8&amp;amp;charSet='UTF8'
    &lt;/property&gt;
    &lt;property name="connection.username"&gt;postgres&lt;/property&gt;
    &lt;property name="connection.password"&gt;pshiv&lt;/property&gt;

    &lt;!-- JDBC connection pool (use the built-in) --&gt;
    &lt;property name="connection.pool_size"&gt;10&lt;/property&gt;

    &lt;!-- SQL dialect --&gt;
    &lt;property name="dialect"&gt;
        org.hibernate.dialect.PostgreSQLDialect
    &lt;/property&gt;

    &lt;!-- Enable Hibernate's automatic session context management --&gt;
    &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt;

    &lt;!-- Disable the second-level cache  --&gt;
    &lt;property name="cache.provider_class"&gt;
        org.hibernate.cache.NoCacheProvider
    &lt;/property&gt;

    &lt;!-- Echo all executed SQL to stdout --&gt;
    &lt;property name="show_sql"&gt;true&lt;/property&gt;

    &lt;!-- Drop and re-create the database schema on startup --&gt;
    &lt;property name="hbm2ddl.auto"&gt;update&lt;/property&gt;



    &lt;mapping class="com.models.Role" /&gt;
    &lt;mapping class="com.models.UserAttempts" /&gt;
    &lt;mapping class="com.models.UserLogin" /&gt;
    &lt;mapping class="com.models.UserRole" /&gt;
    &lt;mapping class="com.models.Program" /&gt;
    &lt;mapping class="com.models.NationalProgram" /&gt;
    &lt;mapping class="com.models.StateProgram" /&gt;
    &lt;mapping class="com.models.OtherProgram" /&gt;
    &lt;mapping class="com.models.Video" /&gt;
    &lt;mapping class="com.models.Contact" /&gt;
    &lt;mapping class="com.models.Heading" /&gt;
&lt;/session-factory&gt;

&lt;/hibernate-configuration&gt;
</code></pre>

<p>My model</p>

<pre><code>package com.models;

import static javax.persistence.GenerationType.IDENTITY;

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

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.Valid;
import javax.validation.constraints.Pattern;

import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.format.annotation.DateTimeFormat;

import com.sun.istack.internal.NotNull;

@Entity
@Table(name = "tbl_heading_info", uniqueConstraints = {
    @UniqueConstraint(columnNames = "id")})
 public class Heading {
 private int id;

@NotNull
@NotBlank
private String message;

@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}

@Column(name = "message", nullable = false)
public String getMessage() {
    return message;
}

public void setMessage(String message) {
    this.message = message;
    /*byte ptext[] = null;
    try {
        ptext = message.getBytes("ISO_8859_1");
    } catch (UnsupportedEncodingException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    try {
        String value = new String(ptext, "UTF-8");
        this.message=value;
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } */

}

}
</code></pre>

<p>In database following is coming</p>

<blockquote>
  <p>àª¸àª°àªàª¾àª°à« àª°à«àª¦àª£àª¾ àª°à«àª¯àª¾...àªàª°à«àª®àªàª¾àª°à«àªàª¨àª¾ àªªàªàª¾àª° àª¹àª®àª£àª¾ àª¨àª¹àª¿ àªµàª§àª¾àª°à«</p>
</blockquote>

<p>Spring configuration</p>

<pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans     
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/mvc 
    http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;

&lt;context:component-scan base-package="com.controller.*" /&gt;
&lt;mvc:annotation-driven validator="validator"&gt;
    &lt;mvc:argument-resolvers&gt;
        &lt;bean class="com.github.dandelion.datatables.extras.spring3.ajax.DatatablesCriteriasMethodArgumentResolver" /&gt;
    &lt;/mvc:argument-resolvers&gt;

&lt;/mvc:annotation-driven&gt;
&lt;mvc:resources mapping="/themes/**" location="/themes/" /&gt;
&lt;mvc:resources mapping="/js/**" location="/js/" /&gt;


&lt;!-- Apache Tiles --&gt;
&lt;bean id="viewResolver"
    class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
    &lt;property name="viewClass"&gt;
        &lt;value&gt;
            org.springframework.web.servlet.view.tiles3.TilesView
        &lt;/value&gt;
    &lt;/property&gt;
    &lt;property name="order" value="0" /&gt;
&lt;/bean&gt;
&lt;bean id="tilesConfigurer"
    class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"&gt;
    &lt;property name="definitions"&gt;
        &lt;list&gt;
            &lt;value&gt;/WEB-INF/tiles.xml&lt;/value&gt;
        &lt;/list&gt;
    &lt;/property&gt;
&lt;/bean&gt;

&lt;!-- Application I18n Message Bundle --&gt;
&lt;bean id="messageSource"
    class="org.springframework.context.support.ReloadableResourceBundleMessageSource"&gt;
    &lt;property name="basename" value="classpath:global" /&gt;
    &lt;property name="defaultEncoding" value="UTF-8" /&gt;
&lt;/bean&gt;

&lt;bean id="localeResolver"
    class="org.springframework.web.servlet.i18n.CookieLocaleResolver"&gt;
    &lt;property name="defaultLocale" value="en" /&gt;
    &lt;property name="cookieName" value="DAMLocaleCookie" /&gt;
    &lt;property name="cookieMaxAge" value="3600" /&gt;
&lt;/bean&gt;
&lt;bean id="localeChangeInterceptor"
    class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"&gt;
    &lt;property name="paramName" value="locale" /&gt;
&lt;/bean&gt;


&lt;!-- Theme Change Interceptor and Resolver definition --&gt;
&lt;bean id="themeSource"
    class="org.springframework.ui.context.support.ResourceBundleThemeSource"&gt;
    &lt;property name="basenamePrefix" value="theme-" /&gt;
&lt;/bean&gt;
&lt;bean id="themeChangeInterceptor"
    class="org.springframework.web.servlet.theme.ThemeChangeInterceptor"&gt;
    &lt;property name="paramName" value="theme" /&gt;
&lt;/bean&gt;
&lt;bean id="themeResolver"
    class="org.springframework.web.servlet.theme.CookieThemeResolver"&gt;
    &lt;property name="defaultThemeName" value="default" /&gt;
&lt;/bean&gt;
&lt;mvc:interceptors&gt;
    &lt;ref bean="localeChangeInterceptor" /&gt;
    &lt;ref bean="themeChangeInterceptor"/&gt;
&lt;/mvc:interceptors&gt;

&lt;!-- Localization of hibernate messages during validation!--&gt;
&lt;bean id="validationMessageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"&gt;
    &lt;property name="basename" value="classpath:validation" /&gt;
&lt;/bean&gt;

&lt;bean name="validator"  class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"&gt;
    &lt;property name="validationMessageSource"&gt;
        &lt;ref bean="validationMessageSource"/&gt;
    &lt;/property&gt;
&lt;/bean&gt;

&lt;bean id="multipartResolver"  class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt;
        &lt;!-- one of the properties available; the maximum file size in bytes --&gt;
    &lt;property name="maxUploadSize" value="9992097152"/&gt;
&lt;/bean&gt;

&lt;bean id="UserLoginDAO" class="com.dao.UserLoginDAOImpl"&gt;&lt;/bean&gt;
&lt;bean id="ProgramDAO" class="com.dao.ProgramDAOImpl"&gt;&lt;/bean&gt;
&lt;bean id="NationalProgramDAO" class="com.dao.NationalProgramDAOImpl"&gt;&lt;/bean&gt;
&lt;bean id="StateProgramDAO" class="com.dao.StateProgramDAOImpl"&gt;&lt;/bean&gt;
&lt;bean id="OtherProgramDAO" class="com.dao.OtherProgramDAOImpl"&gt;&lt;/bean&gt;
&lt;bean id="VideoDAO" class="com.dao.VideoDAOImpl"&gt;&lt;/bean&gt;
&lt;bean id="ContactDAO" class="com.dao.ContactDAOImpl"&gt;&lt;/bean&gt;
&lt;bean id="HeadingDAO" class="com.dao.HeadingDAOImpl"&gt;&lt;/bean&gt;

&lt;/beans&gt;
</code></pre>

<p>web.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt;

&lt;display-name&gt;Jay hind express&lt;/display-name&gt;

&lt;welcome-file-list&gt;
    &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
&lt;/welcome-file-list&gt;

&lt;!-- Spring MVC --&gt;
&lt;servlet&gt;
    &lt;servlet-name&gt;jayhind-dispatcher&lt;/servlet-name&gt;
    &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
    &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
&lt;/servlet&gt;
&lt;servlet-mapping&gt;
    &lt;servlet-name&gt;jayhind-dispatcher&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;

&lt;listener&gt;
    &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
&lt;/listener&gt;

&lt;context-param&gt;
    &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
    &lt;param-value&gt;
        /WEB-INF/spring-database.xml,
        /WEB-INF/spring-security.xml
    &lt;/param-value&gt;
&lt;/context-param&gt;

&lt;!-- Spring Security --&gt;
&lt;filter&gt;
    &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
    &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
&lt;/filter&gt;

&lt;filter-mapping&gt;
    &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
    &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
&lt;/filter-mapping&gt;

&lt;!-- Dandelion-Datatables servlet definition --&gt;
&lt;servlet&gt;
    &lt;servlet-name&gt;datatablesController&lt;/servlet-name&gt;
    &lt;servlet-class&gt;com.github.dandelion.datatables.extras.servlet2.servlet.DatatablesServlet&lt;/servlet-class&gt;
&lt;/servlet&gt;
&lt;servlet-mapping&gt;
    &lt;servlet-name&gt;datatablesController&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/datatablesController/*&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;

&lt;!-- Dandelion servlet definition and mapping --&gt;
&lt;servlet&gt;
  &lt;servlet-name&gt;dandelionServlet&lt;/servlet-name&gt;
  &lt;servlet-class&gt;com.github.dandelion.core.web.DandelionServlet&lt;/servlet-class&gt;
  &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;
&lt;/servlet&gt;
&lt;servlet-mapping&gt;
  &lt;servlet-name&gt;dandelionServlet&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/dandelion-assets/*&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;

&lt;!-- Dandelion filter definition and mapping --&gt;
&lt;filter&gt;
  &lt;filter-name&gt;dandelionFilter&lt;/filter-name&gt;
  &lt;filter-class&gt;com.github.dandelion.core.web.DandelionFilter&lt;/filter-class&gt;
&lt;/filter&gt;
&lt;filter-mapping&gt;
  &lt;filter-name&gt;dandelionFilter&lt;/filter-name&gt;
  &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
&lt;/filter-mapping&gt;

&lt;!-- Dandelion-Datatables filter used for basic export --&gt;
&lt;filter&gt;
   &lt;filter-name&gt;datatables&lt;/filter-name&gt;
   &lt;filter-class&gt;com.github.dandelion.datatables.core.web.filter.DatatablesFilter&lt;/filter-class&gt;
&lt;/filter&gt;
&lt;filter-mapping&gt;
   &lt;filter-name&gt;datatables&lt;/filter-name&gt;
   &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
&lt;/filter-mapping&gt; 
&lt;filter&gt;
&lt;filter-name&gt;SetCharacterEncodingFilter&lt;/filter-name&gt;
&lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt;
&lt;init-param&gt;
    &lt;param-name&gt;encoding&lt;/param-name&gt;
    &lt;param-value&gt;UTF8&lt;/param-value&gt;
&lt;/init-param&gt;
&lt;init-param&gt;
    &lt;param-name&gt;forceEncoding&lt;/param-name&gt;
    &lt;param-value&gt;true&lt;/param-value&gt;
&lt;/init-param&gt;
&lt;/filter&gt;
&lt;filter-mapping&gt;
&lt;filter-name&gt;SetCharacterEncodingFilter&lt;/filter-name&gt;
&lt;url-pattern&gt;/*&lt;/url-pattern&gt;
&lt;/filter-mapping&gt;
&lt;/web-app&gt;
</code></pre>

<p>In  JSP</p>

<pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%&gt;
&lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;
&lt;%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%&gt;
&lt;%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt;
&lt;div class="art-layout-wrapper"&gt;
&lt;div class="art-content-layout"&gt;
    &lt;div class="art-content-layout-row"&gt;
        &lt;div class="art-layout-cell art-content"&gt;
            &lt;article class="art-post art-article"&gt;


                &lt;div class="art-postcontent art-postcontent-0 clearfix"&gt;
                    &lt;div class="art-content-layout"&gt;
                        &lt;div class="art-content-layout-row"&gt;
                            &lt;div class="art-layout-cell layout-item-0" style="width: 100%"&gt;
                                &lt;p&gt;
                                    &lt;span style="font-weight: bold;font-color:red;"&gt;Breaking News :
                                    &lt;form:form id="programForm" name="programForm" modelAttribute="heading" method='POST' action="updateHeading" &gt; 
                                    &lt;table style="width: 100%"&gt;
                                        &lt;tr&gt;
                                            &lt;td colspan="3" align="center"&gt;
                                                &lt;c:if test="${not empty error}"&gt;
                                                    &lt;div class="errorMSG"&gt;${error}&lt;/div&gt;
                                                &lt;/c:if&gt;
                                                &lt;c:if test="${not empty msg}"&gt;
                                                    &lt;div class="msg"&gt;${msg}&lt;/div&gt;
                                                &lt;/c:if&gt;
                                            &lt;/td&gt;
                                        &lt;/tr&gt;
                                        &lt;spring:bind path="message"&gt;
                                        &lt;tr class="&lt;c:if test="${status.error}"&gt; trError &lt;/c:if&gt;" style="width:300px;"&gt;
                                            &lt;th class="headerRow thWidth"&gt;
                                                &lt;form:label path="message"&gt;
                                                    Breaking News :
                                                &lt;/form:label&gt;
                                            &lt;/th&gt;
                                            &lt;td style="width:40%;"&gt;
                                                &lt;form:textarea path="message" id="message" maxlength="200" size="25"/&gt;
                                                &lt;form:hidden path="id"/&gt;
                                            &lt;/td&gt;
                                            &lt;td style="width:30%;"&gt;
                                                &lt;form:errors path="message"&gt;&lt;/form:errors&gt;
                                                &lt;label for="message" class="error"&gt;&lt;/label&gt;
                                            &lt;/td&gt;
                                        &lt;/tr&gt;
                                        &lt;tr&gt;
                                            &lt;td colspan="3" align="center"&gt;
                                                &lt;input name="submit" type="submit" value="Update Breaking News" class="button"/&gt;
                                            &lt;/td&gt;
                                        &lt;/tr&gt;
                                        &lt;/spring:bind&gt;
                                    &lt;/table&gt;
                                    &lt;/form:form&gt;
                                    &lt;/span&gt;
                                &lt;/p&gt;


                            &lt;/div&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;

            &lt;/article&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</code></pre>