I am trying to connect to Postgresql9.1 in ubuntu with pgadmin3. My Pgadmin3 GUI tool does not give any option to create tables by right clicking the database, but it is ava
If you have your hibernate.cfg.xml in the root of the source folder, just do
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
If it is in the package, for an example in the org.nitish.caller, specify path by this way
SessionFactory sessionFactory = new Configuration()
.configure("/org/nitish/caller/hibernate.cfg.xml").buildSessionFactory();
You need to close the session (in the finally block). Don't forget to add rollback code.
Please, add @Table annotation to the UserDetails.
Update
The reason of the error that Hibernate can't find org.postgresql.Driver class. It resides in postgresql jar. You have that jar at your image, but may be you don't add it to the classpath. Refer How to Add JARs to Project Build Paths in Eclipse (Java).
To close a session in the finally block you need to have session variable outside the try block.
Session session = sessionFactory.openSession();
try{
} finally {
session.close();
}