autorunman22 0 Light Poster

it always output this error:

Feb 07, 2012 11:25:32 AM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
Feb 07, 2012 11:25:32 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.0.1.Final}
Feb 07, 2012 11:25:32 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Feb 07, 2012 11:25:32 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Feb 07, 2012 11:25:32 AM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
Feb 07, 2012 11:25:32 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
Could not parse configuration: /hibernate.cfg.xml
Exception in thread "main" java.lang.NullPointerException
	at MyExample.main(MyExample.java:27)

im only trying to do this tutorial http://www.skill-guru.com/blog/2009/08/05/first-hibernate-tutorial-%E2%80%93get-hands-on-experience/#more-259
but I used oracle instead of mysql.

this is my hibernate.cfg.xml file:

<? xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE hibernate-configuration PUBLIC
"- / / Hibernate / Hibernate Coniguration DTD 3.0 / / EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property>oracle.jdbc.driver.OracleDriver</property>
<property>jdbc:oracle:thin:@//127.0.0.1:1521/XE</property>
<property>jim</property>
<property>oracle</property>
<property>10</property>
<property>true</property>
<property>org.hibernate.dialect.Oracle10gDialect</property>
<property>update</property>
<!– Mapping files –>
<mapping resource=”contact.hbm.xml”/>
</session-factory>
</hibernate-configuration>

and this is my contact.hbm.xml file:

<?xml version=”1.0??>
<!DOCTYPE hibernate-mapping PUBLIC
“-//Hibernate/Hibernate Mapping DTD 3.0//EN”
“http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd“>

<hibernate-mapping>
<class name=”Contact” table=”CONTACT”>
<id name=”id” type=”long” column=”ID” >
<generator/>
</id>

<property name=”firstName”>
<column name=”FIRSTNAME” />
</property>
<property name=”lastName”>
<column name=”LASTNAME”/>
</property>
<property name=”email”>
<column name=”EMAIL”/>
</property>
</class>
</hibernate-mapping>

this is my MyExample.java file:

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class MyExample {
public static void main(String[] args) {
Session session = null;

try{
// This step will read hibernate.cfg.xml and prepare hibernate for use
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
//Create new instance of Contact and set values in it by reading them from form object
System.out.println("Inserting Record");
Contact contact = new Contact();
contact.setId(3);
contact.setFirstName("Smitha");
contact.setLastName("Rao");
contact.setEmail("smithaxxx@yahoo.com");
session.save(contact);

System.out.println("Done");
}catch(Exception e){
System.out.println(e.getMessage());
}finally{
// Actual contact insertion will happen at this step
session.flush();
session.close();

}

}

}

and lastly, the Contact class file:

public class Contact {
private String firstName;
private String lastName;
private String email;
private long id; public String getEmail() {
return email;
} public String getFirstName() {
return firstName;
} public String getLastName() {
return lastName;
} public void setEmail(String string) {
email = string;
} public void setFirstName(String string) {
firstName = string;
} public void setLastName(String string) {
lastName = string;
} public long getId() {
return id;
} public void setId(long l) {
id = l;
}}

can you tell me what's the wrong move here? thanks in advanced!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.