Could not find oracle dialect,
June 21, 2007 at 11:19 AM
Hi I am getting the following error can anybody help.
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). log4j:WARN Please initialize the log4j system properly. java.lang.NullPointerException at roseindia.tutorial.hibernate.FirstExample.main(FirstExample.java:40) Dialect class not found: net.sf.hibernate.dialect.Oracle9Dialect Exception in thread "main"
/** * @author Deepak Kumar * * Java Class to map to the datbase Contact Table */ public class Contact { private String firstName; private String lastName; private String email; private long id;
import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import org.hibernate.Transaction; import java.sql.SQLException; /** * @author Deepak Kumar * * http://www.roseindia.net * Hibernate example to inset data into Contact table */ public class FirstExample { 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(); Transaction tx=session.beginTransaction(); //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("Deepak"); contact.setLastName("Kumar"); contact.setEmail("deepak_38@yahoo.com"); session.save(contact); tx.commit(); System.out.println("Done"); }catch(Exception e){ System.out.println(e.getMessage());
}finally{ // Actual contact insertion will happen at this step session.flush(); try{ session.connection().commit(); } catch(SQLException e) { System.out.println(e.getMessage()) ; }