title: java hibernate database connection
body: <p>I am new to Hibernate. I am trying to make a simple database driven application using Hibernate. But I am stuck. I can't even run a simple database query. I am getting this error:</p>
  
  <p><img src="https://i.stack.imgur.com/YbJxA.png" alt="log file generated while running the program">
  <img src="https://i.stack.imgur.com/YbJxA.png" alt=""></p>
  
  <p><strong>hibernate.cfg.xml:</strong></p>
  
  <pre class="lang-xml prettyprint-override"><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.dialect"&gt;org.hibernate.dialect.DerbyDialect&lt;/property&gt;
      &lt;property name="hibernate.connection.driver_class"&gt;org.apache.derby.jdbc.ClientDriver&lt;/property&gt;
      &lt;property name="hibernate.connection.url"&gt;jdbc:derby://localhost:1527/dbtest &lt;/property&gt;
      &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;
      &lt;property name="connection.password"&gt;pass&lt;/property&gt;
      &lt;property name="hibernate.connection.autocommit"&gt;false&lt;/property&gt;
       &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt;
      &lt;property name = "show_sql"&gt;true&lt;/property&gt;
      &lt;property name = "format_sql"&gt;true&lt;/property&gt;
      &lt;property name = "hibernate.transaction.factory_class"&gt;org.hibernate.testing.cache.CachingRegionFactory     
  &lt;/property&gt;
      &lt;property name = "hibernate.hbm2ddl.auto"&gt;create&lt;/property&gt;
      &lt;mapping resource="com/enroll/hibernate.hbm.xml"&gt;&lt;/mapping&gt;
      &lt;mapping class = "com/enroll/insert"&gt;&lt;/mapping&gt;    
    &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p><strong>hibernate.hbm.xml:</strong></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&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 catalog="user" name="com.enroll.UserDetail" table="users"/&gt;
    &lt;id column="id" name="id" type="java.lang.Integer"&gt;
      &lt;generator class="assigned"/&gt;
    &lt;/id&gt;
    &lt;property column="uname" name="uname" type="string"/&gt;
     &lt;property column="pword" name="pword" type="string"/&gt;   
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p><strong>UserDetail.java:</strong></p>
  
  <pre><code>/*
   * To change this license header, choose License Headers in Project Properties.
   * To change this template file, choose Tools | Templates
   * and open the template in the editor.
   */
  package com.enroll;
  
  import javax.persistence.Entity;
  import javax.persistence.Id;
  
  @Entity
  public class UserDetail {
     @Id private int id;
      String uname;
      String pword;
  
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      public String getUname() {
          return uname;
      }
  
      public void setUname(String uname) {
          this.uname = uname;
      }
  
      public String getPword() {
          return pword;
      }
  
      public void setPword(String pword) {
          this.pword = pword;
      }
  }
  </code></pre>
  
  <p><strong>insert.java:</strong></p>
  
  <pre><code>/*
   * To change this license header, choose License Headers in Project Properties.
   * To change this template file, choose Tools | Templates
   * and open the template in the editor.
   */
  
  package com.enroll;
  
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.ResultSet;
  import java.sql.Statement;
  import java.util.Date;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.Transaction;
  import org.hibernate.cfg.Configuration;
  
  public class insert {
      public static void main(String[] args){
         UserDetail user1 = new UserDetail();
         user1.setId(7);
         user1.setUname("shri");
         user1.setPword("password");
  
  
         SessionFactory sf = (SessionFactory) new Configuration().configure("hibernate.cfg.xml").buildSessionFactory();
         Session session = sf.openSession();
         session.beginTransaction();
         session.save(user1);
         session.getTransaction().commit();       
      }
  }  
  
  Can any one please tell me where I am wrong and what I should do? 
  
    [1]: http://i.stack.imgur.com/YbJxA.png
  </code></pre>