title: nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection] with root cause
body: <p><strong>While i'm trying to save my data, tomcat(7.0.14.0) shows following error.</strong></p>
  
  <pre><code>INFO: Initializing Spring FrameworkServlet 'mvc-dispatcher'
  Mar 10, 2016 8:19:32 AM org.apache.catalina.core.StandardWrapperValve invoke
  SEVERE: Servlet.service() for servlet [mvc-dispatcher] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection] with root cause
      java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
          at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
          at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)
          at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)
          at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919)
          at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4004)
          at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1284)
          at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2312)
          at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2122)
          at com.mysql.jdbc.ConnectionImpl.&lt;init&gt;(ConnectionImpl.java:774)
          at com.mysql.jdbc.JDBC4Connection.&lt;init&gt;(JDBC4Connection.java:49)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
          at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
          at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
          at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:375)
          at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:289)
          at java.sql.DriverManager.getConnection(DriverManager.java:571)
          at java.sql.DriverManager.getConnection(DriverManager.java:187)
          at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:173)
          at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:164)
          at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:149)
          at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:119)
          at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81)
          at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
          at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
          at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119)
          at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
          at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
          at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:555)
          at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
          at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:335)
          at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105)
          at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
          at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
          at com.sun.proxy.$Proxy20.saveRole(Unknown Source)
          at com.secl.springmvc.controller.RoleController.saveRole(RoleController.java:43)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:606)
          at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:212)
          at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
          at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
          at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
          at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
          at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
          at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
          at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
          at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
          at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
          at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
          at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:317)
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:204)
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:182)
          at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:311)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
          at java.lang.Thread.run(Thread.java:745)   
  </code></pre>
  
  <hr>
  
  <pre><code>&gt; pom.xml
  
      &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
          &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
          &lt;groupId&gt;com.mycompany&lt;/groupId&gt;
          &lt;artifactId&gt;OWOM&lt;/artifactId&gt;
          &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
          &lt;packaging&gt;war&lt;/packaging&gt;
  
          &lt;name&gt;OWOM&lt;/name&gt;
  
          &lt;properties&gt;
              &lt;endorsed.dir&gt;${project.build.directory}/endorsed&lt;/endorsed.dir&gt;
              &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
              &lt;netbeans.hint.deploy.server&gt;Tomcat&lt;/netbeans.hint.deploy.server&gt;
              &lt;spring.version&gt;3.1.0.RELEASE&lt;/spring.version&gt;
      &lt;!--       &lt;spring.version&gt;3.2.6.RELEASE&lt;/spring.version&gt;--&gt;
          &lt;/properties&gt;
  
          &lt;dependencies&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
                  &lt;artifactId&gt;hibernate&lt;/artifactId&gt;
                  &lt;version&gt;3.2.5.ga&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
                  &lt;artifactId&gt;ejb3-persistence&lt;/artifactId&gt;
                  &lt;version&gt;1.0.1.GA&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
                  &lt;artifactId&gt;hibernate-annotations&lt;/artifactId&gt;
                  &lt;version&gt;3.4.0.GA&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
                  &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
                  &lt;version&gt;3.4.0.GA&lt;/version&gt;
              &lt;/dependency&gt;
      &lt;!--        &lt;dependency&gt;
                  &lt;groupId&gt;javax.sql&lt;/groupId&gt;
                  &lt;artifactId&gt;jdbc-stdext&lt;/artifactId&gt;
                  &lt;version&gt;2.0&lt;/version&gt;
              &lt;/dependency&gt;--&gt;
              &lt;!--MYSQL Connector --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;mysql&lt;/groupId&gt;
                  &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
                  &lt;version&gt;5.1.13&lt;/version&gt;
              &lt;/dependency&gt; 
      &lt;!--        &lt;dependency&gt;
                  &lt;groupId&gt;javax&lt;/groupId&gt;
                  &lt;artifactId&gt;javaee-web-api&lt;/artifactId&gt;
                  &lt;version&gt;6.0&lt;/version&gt;
                  &lt;scope&gt;provided&lt;/scope&gt;
              &lt;/dependency&gt;
                                      --&gt;
  
              &lt;dependency&gt;
                  &lt;groupId&gt;antlr&lt;/groupId&gt;
                  &lt;artifactId&gt;antlr&lt;/artifactId&gt;
                  &lt;version&gt;2.7.7&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;aopalliance&lt;/groupId&gt;
                  &lt;artifactId&gt;aopalliance&lt;/artifactId&gt;
                  &lt;version&gt;1.0&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
                  &lt;version&gt;3.1.0.RELEASE&lt;/version&gt;
      &lt;!--          &lt;version&gt;3.0.0.RELEASE&lt;/version&gt;--&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
                  &lt;version&gt;3.1.0.RELEASE&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
                  &lt;version&gt;3.1.0.RELEASE&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
                  &lt;version&gt;3.1.0.RELEASE&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-expression&lt;/artifactId&gt;
                  &lt;version&gt;3.1.0.RELEASE&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
                  &lt;version&gt;3.1.0.RELEASE&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
                  &lt;version&gt;3.1.0.RELEASE&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
                  &lt;version&gt;3.1.0.RELEASE&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
                  &lt;version&gt;3.1.0.RELEASE&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
                  &lt;version&gt;3.1.0.RELEASE&lt;/version&gt;
              &lt;/dependency&gt;
      &lt;!--        &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-aspects&lt;/artifactId&gt;
                  &lt;version&gt;3.1.0.RELEASE&lt;/version&gt;
              &lt;/dependency&gt;       --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;commons-dbcp&lt;/groupId&gt;
                  &lt;artifactId&gt;commons-dbcp&lt;/artifactId&gt;
                  &lt;version&gt;1.4&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
                  &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
                  &lt;version&gt;3.6.0.Final&lt;/version&gt;
              &lt;/dependency&gt;
  
  
  
          &lt;!--&lt;dependency&gt;
                  &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
                  &lt;artifactId&gt;slf4j-jcl&lt;/artifactId&gt;
                  &lt;version&gt;${sl4j.version}&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
                  &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
                  &lt;version&gt;${sl4j.version}&lt;/version&gt;
              &lt;/dependency&gt; --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.hsqldb&lt;/groupId&gt;
                  &lt;artifactId&gt;hsqldb&lt;/artifactId&gt;
                  &lt;version&gt;2.0.0&lt;/version&gt;
                  &lt;scope&gt;runtime&lt;/scope&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;javax.transaction&lt;/groupId&gt;
                  &lt;artifactId&gt;jta&lt;/artifactId&gt;
      &lt;!--            &lt;version&gt;1.0.1B&lt;/version&gt;--&gt;
                  &lt;version&gt;1.1&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;log4j&lt;/groupId&gt;
                  &lt;artifactId&gt;log4j&lt;/artifactId&gt;
                  &lt;version&gt;1.2.15&lt;/version&gt;
                  &lt;exclusions&gt;
                      &lt;exclusion&gt;
                          &lt;groupId&gt;com.sun.jmx&lt;/groupId&gt;
                          &lt;artifactId&gt;jmxri&lt;/artifactId&gt;
                      &lt;/exclusion&gt;
                      &lt;exclusion&gt;
                          &lt;groupId&gt;com.sun.jdmk&lt;/groupId&gt;
                          &lt;artifactId&gt;jmxtools&lt;/artifactId&gt;
                      &lt;/exclusion&gt;
                      &lt;exclusion&gt;
                          &lt;groupId&gt;javax.jms&lt;/groupId&gt;
                          &lt;artifactId&gt;jms&lt;/artifactId&gt;
                      &lt;/exclusion&gt;
                  &lt;/exclusions&gt;
              &lt;/dependency&gt;
  
              &lt;dependency&gt;
                  &lt;groupId&gt;junit&lt;/groupId&gt;
                  &lt;artifactId&gt;junit&lt;/artifactId&gt;
                  &lt;version&gt;4.9&lt;/version&gt;
                  &lt;scope&gt;test&lt;/scope&gt;
              &lt;/dependency&gt;
          &lt;/dependencies&gt;
  
          &lt;build&gt;
              &lt;plugins&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                      &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                      &lt;version&gt;2.3.2&lt;/version&gt;
                      &lt;configuration&gt;
                          &lt;source&gt;1.6&lt;/source&gt;
                          &lt;target&gt;1.6&lt;/target&gt;
                          &lt;compilerArguments&gt;
                              &lt;endorseddirs&gt;${endorsed.dir}&lt;/endorseddirs&gt;
                          &lt;/compilerArguments&gt;
                      &lt;/configuration&gt;
                  &lt;/plugin&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                      &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                      &lt;version&gt;2.1.1&lt;/version&gt;
                      &lt;configuration&gt;
                          &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
                      &lt;/configuration&gt;
                  &lt;/plugin&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                      &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
                      &lt;version&gt;2.1&lt;/version&gt;
                      &lt;executions&gt;
                          &lt;execution&gt;
                              &lt;phase&gt;validate&lt;/phase&gt;
                              &lt;goals&gt;
                                  &lt;goal&gt;copy&lt;/goal&gt;
                              &lt;/goals&gt;
                              &lt;configuration&gt;
                                  &lt;outputDirectory&gt;${endorsed.dir}&lt;/outputDirectory&gt;
                                  &lt;silent&gt;true&lt;/silent&gt;
                                  &lt;artifactItems&gt;
                                      &lt;artifactItem&gt;
                                          &lt;groupId&gt;javax&lt;/groupId&gt;
                                          &lt;artifactId&gt;javaee-endorsed-api&lt;/artifactId&gt;
                                          &lt;version&gt;6.0&lt;/version&gt;
                                          &lt;type&gt;jar&lt;/type&gt;
                                      &lt;/artifactItem&gt;
                                  &lt;/artifactItems&gt;
                              &lt;/configuration&gt;
                          &lt;/execution&gt;
                      &lt;/executions&gt;
                  &lt;/plugin&gt;
              &lt;/plugins&gt;
          &lt;/build&gt;
          &lt;repositories&gt;
              &lt;repository&gt;
                  &lt;url&gt;http://download.java.net/maven/2/&lt;/url&gt;
                  &lt;id&gt;hibernate-persistence&lt;/id&gt;
                  &lt;layout&gt;default&lt;/layout&gt;
                  &lt;name&gt;Repository for library Library[hibernate-persistence]&lt;/name&gt;
              &lt;/repository&gt;
              &lt;repository&gt;
                  &lt;id&gt;java.net&lt;/id&gt;
                  &lt;url&gt;http://download.java.net/maven/2/&lt;/url&gt;
              &lt;/repository&gt;
          &lt;/repositories&gt;
      &lt;/project&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>&gt; mvc-dispatcher-servlet.xml
  
  
  
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xmlns:mvc="http://www.springframework.org/schema/mvc" 
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="http://www.springframework.org/schema/beans 
                          http://www.springframework.org/schema/beans/spring-beans.xsd
                          http://www.springframework.org/schema/tx 
                          http://www.springframework.org/schema/tx/spring-tx.xsd
                          http://www.springframework.org/schema/mvc 
                          http://www.springframework.org/schema/mvc/spring-mvc.xsd
                          http://www.springframework.org/schema/context 
                          http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
      &lt;!-- Specifying base package of the Components like Controller, Service, 
      DAO --&gt;
  
      &lt;context:component-scan base-package="com.demo.springmvc" /&gt;
  
      &lt;!-- Getting Database properties --&gt;
      &lt;context:property-placeholder location="\WEB-INF\app.properties" /&gt;
  
      &lt;mvc:annotation-driven /&gt;
  
  
          &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
              &lt;property name="prefix"&gt;
                  &lt;value&gt;/WEB-INF/views/&lt;/value&gt;
              &lt;/property&gt;
              &lt;property name="suffix"&gt;
                  &lt;value&gt;.jsp&lt;/value&gt;
              &lt;/property&gt;
          &lt;/bean&gt;    
  
      &lt;!-- DataSource --&gt;   
  
      &lt;!--  &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;--&gt;
            &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
              &lt;property name="driverClassName" value="${jdbc.driverClassName}"/&gt;
              &lt;property name="url" value="${jdbc.url}"/&gt;
              &lt;property name="username" value="${db.user}"/&gt;
              &lt;property name="password" value="${db.pass}"/&gt;
          &lt;/bean&gt;
      &lt;!-- Hibernate SessionFactory --&gt;   
          &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;
              &lt;property name="dataSource" ref="dataSource"&gt;&lt;/property&gt;
              &lt;property name="hibernateProperties"&gt;
                  &lt;props&gt;
                      &lt;prop key="hibernate.dialect"&gt;${hibernate.dialect}&lt;/prop&gt;
                      &lt;prop key="hibernate.show_sql"&gt;${hibernate.show_sql}&lt;/prop&gt;
                      &lt;prop key="hibernate.format_sql"&gt;${hibernate.format_sql}&lt;/prop&gt;
                      &lt;prop key="hibernate.generate_statistics"&gt;${hibernate.generate_statistics}&lt;/prop&gt;
  
                  &lt;/props&gt;
              &lt;/property&gt;
  
       &lt;/bean&gt;      
       &lt;!-- Transaction --&gt;
      &lt;bean id="transactionManager"
      class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
      &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;       
      &lt;/beans&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>&gt; web.xml
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;web-app xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
       version="3.0"&gt;
      &lt;display-name&gt;DEMO&lt;/display-name&gt;
  &lt;servlet&gt;
     &lt;servlet-name&gt;mvc-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;mvc-dispatcher&lt;/servlet-name&gt;
     &lt;url-pattern&gt;/OWOM/*&lt;/url-pattern&gt;
   &lt;/servlet-mapping&gt;
  
  &lt;context-param&gt;
     &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
     &lt;param-value&gt;/WEB-INF/mvc-dispatcher-servlet.xml&lt;/param-value&gt;
   &lt;/context-param&gt;
  
   &lt;listener&gt;
     &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
   &lt;/listener&gt;
      &lt;session-config&gt;
          &lt;session-timeout&gt;
              30
          &lt;/session-timeout&gt;
      &lt;/session-config&gt;
      &lt;welcome-file-list&gt;
       &lt;welcome-file&gt;/WEB-INF/views/login.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>&gt; app.properties
  
      jdbc.driverClassName =com.mysql.jdbc.Driver
      jdbc.url =jdbc:mysql://localhost:3306/test
      db.user =root
      db.pass= =root
      #Hibernate
      hibernate.dialect =org.hibernate.dialect.MySQLDialect
      hibernate.show_sql =true
      hibernate.format_sql =true
      hibernate.generate_statistics=true
  </code></pre>