1
  <form action="register.jsp" method="post">
id:<input type="text" name="id"/><br><br/>
Name:<input type="text" name="name"/><br><br/>
Password:<input type="password" name="password"/><br><br/>
Email ID:<input type="text" name="email"/><br><br/>
<input type="submit" value="register"/>

</form>

the above file is index.jsp

<%@page import="com.javatpoint.mypack.UserDao"%>
<jsp:useBean id="obj" class="com.javatpoint.mypack.User"></jsp:useBean>
<jsp:setProperty property="*" name="obj"/>
<%
obj.setName(request.getParameter("name"));
obj.setPassword(request.getParameter("password"));
obj.setEmail(request.getParameter("email"));
try
{
System.out.println("--------->"+obj.getName());

int i=UserDao.register(obj);
if(i>0)
{
out.print("You are successfully registered");
}
else
{
    out.print("registration failed");
}
}
catch(Exception e)
{

    out.print("You are not registered");
}
%>

the above file is register.jsp

package com.javatpoint.mypack;

public class User {
public int id;
public String name,password,email;

public int getId() {
    return id;
}
public void setId(int id) {
    this.id = id;
}
public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}
public String getPassword() {
    return password;
}
public void setPassword(String password) {
    this.password = password;
}
public String getEmail() {
    return email;
}
public void setEmail(String email) {
    this.email = email;
}


}

the above file is user.java

package com.javatpoint.mypack;


import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.*;

public class UserDao {

    public static int register(User u){
        int i=0;
        try{

        Session session=new Configuration().configure().buildSessionFactory().openSession();

        Transaction t=session.beginTransaction();
        t.begin();

        i=(Integer)session.save(u);

        t.commit();
        session.close();
        }catch (Exception e) {
            e.printStackTrace();
        }
        return i;
    }

}

the above program is UserDao.java while executing the application it is hibernate.properties not found error please reply me why it is occuring

vikasramireddy
  • 88
  • 1
  • 10

2 Answers2

0

Hibernate by default at startup looks for hibernate.properties and hibernate.cfg.xml and logs a debug message if those aren't found. So disable debug/info for hibernate and you will not see the message.see http://forum.springsource.org/showthread.php?127317-hibernate-properties-with-JavaConfig

also see hibernate properties not found

Community
  • 1
  • 1
M Sach
  • 33,416
  • 76
  • 221
  • 314
0

Make sure .properties file in the root of class path, Which means if you have something like

--src //source folder which all files in it will be compiled/copied to deployment
   --user   //those are folders which has classes in it
   --dao    //those are folders which has classes in it
  hibernate.properties //should be here

if it is above structure then new Configuration().configure() should find it automatically, or if you do not want to put it there then you can do something like: new Configuration().configure(path) Or see this answer

Community
  • 1
  • 1
Elbek
  • 3,434
  • 6
  • 37
  • 49
  • i execute the above program as u said but even it showing the same error.if had any example program on jsp as front end and hibernate as backend plz post the link – vikasramireddy Jul 05 '13 at 05:57