• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Hibernate configuration

Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am creating a Hibernate application

package com.jlcindia.hibernate;
public class Customer {

private int cid;
private String cname;
private String emal;
private long phone;
private String city;
private double bal;

public Customer(){}
public Customer(String cname,String emal,long phone,String city,double bal){




My application

package com.jlcindia.hibernate;
import org.hibernate.*;
import org.hibernate.cfg.*;

public class Lab1A {

public static void main(String[] args) {
// TODO Auto-generated method stub
Transaction tx=null;
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();

Session session = sessionFactory.openSession();
Customer cust=new Customer("sri","sri@jlc.com",1234,"blore",25000.0);
System.out.println("record inserted");

catch(Exception e){



Configuraton file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

   <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
   <property name="hibernate.connection.url">jdbcracle:thin:@localhost:1521:XE</property>
   <property name="username">system</property>
   <property name="password">Srikant1</property>
   <property name="dialect">org.hibernate.dialect.OracleDialect</property>
   <property name="show_sql">true</property>
   <mapping resource="com/jlcindia/hibernate/Customer.hbm.xml"/>

Mapping file

<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping package="com.jlc.india.hibernate">
<class name="Customer" table="customers">
<id name="cid" column="cid" type="int">
<generator class="increment"/>
<property name="cname"/>
<property name="emal" column="emal"/>
<property name="phone" column="phone" type="long"/>
<property name="city" column="city"   type="string"/>

<property name="bal" column="bal" type="double"/>

But i am getting this error

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2246)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2158)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2137)
at com.jlcindia.hibernate.Lab1A.main(Lab1A.java:11)
Caused by: org.dom4j.DocumentException: Error on line 30 of document  : The markup in the document following the root element must be well-formed. Nested exception: The markup in the document following the root element must be well-formed.
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2238)
... 3 more
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know much but this line stuck out as different to the rest, not having a column attribute
Wendy Gibbons
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also just spotted this:

none of the files you gave us are long enough to have a line 30? have you checked out that?
She said she got a brazillian. I think owning people is wrong. That is how I learned ... tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic