title: how to resolve ==> org.hibernate.exception.GenericJDBCException: Could not open connection
body: <p>when i execute my Main class i get this execution
  cant figure out the issue point</p>
  
  <p>the error comes in the line
  Transaction tr = session.beginTransaction();</p>
  
  <p>error stack says :</p>
  
  <pre><code>ERROR: Access denied for user 'root'@'localhost' (using password: NO)
  error===&gt;org.hibernate.exception.GenericJDBCException: Could not open connection
  </code></pre>
  
  <p>my Main class File :</p>
  
  <pre><code>package com.hussi.model;
  
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.Transaction;
  import org.hibernate.cfg.Configuration;
  
  public class Main {
      public static void main(String[] args) 
      {
          User user = new User();
          user.setUser_id(1);
          user.setUsername("hussi");
          user.setPassword("maria");
          SessionFactory sesionFactory = new Configuration().configure().buildSessionFactory() ;
          Session session = sesionFactory.openSession();
          try{
          Transaction tr = session.beginTransaction();
          session.save(user);
          }
          catch(Exception e)
          {
              System.out.println("error===&gt;"+e);
          }
  
          finally
          {
          session.flush();
          session.close();
          }
      }
  
  }
  </code></pre>
  
  <p>my model file</p>
  
  <pre><code>package com.hussi.model;
  
  public class User 
  {
      int user_id;
      String username;
      String password;
  
      public int getUser_id() {
          return user_id;
      }
      public void setUser_id(int user_id) {
          this.user_id = user_id;
      }
  
  
      public String getUsername() {
          return username;
      }
      public void setUsername(String username) {
          this.username = username;
      }
  
  
      public String getPassword() {
          return password;
      }
      public void setPassword(String password) {
          this.password = password;
      }
  
      public String toString()
      {
          return "username==&gt;"+this.username+" : password==&gt;"+this.password;
      }
  
  }
  </code></pre>
  
  <p>my user.hbm.xml file</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE hibernate-mapping PUBLIC 
  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt;
  
  &lt;hibernate-mapping&gt;
      &lt;class name="com.hussi.model.User" table="users"&gt;
           &lt;id name="user_id" type="int" column="user_id"&gt;
              &lt;generator class="increment" /&gt;
          &lt;/id&gt;
  
          &lt;property name="username"&gt;
              &lt;column name="username"/&gt;
          &lt;/property&gt;
  
          &lt;property name="password"&gt;
              &lt;column name="password"/&gt;
          &lt;/property&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>my hibernate configuration file : hibernate.cfg.xml</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://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
      &lt;session-factory&gt;
          &lt;!-- Database connection settings --&gt;
          &lt;property name="connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
          &lt;property name="connection.url"&gt;jdbc:mysql://localhost:3306/my_hibernate_1&lt;/property&gt;
          &lt;property name="connection.username"&gt;root&lt;/property&gt;
          &lt;property name="connecttion.password"&gt;root&lt;/property&gt;
  
          &lt;!-- Database connection settings --&gt;
          &lt;property name="connection.pool_size"&gt;1&lt;/property&gt;
  
          &lt;!-- MySql Dialect --&gt;
          &lt;property name="dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
  
          &lt;!-- Echo all executed SQL to stdout --&gt;
          &lt;property name="show_sql"&gt;false&lt;/property&gt;
  
          &lt;mapping resource="user.hbm.xml"/&gt;
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>