-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Connection cannot be null when 'hibernate.dialect' not set
PostPosted: Mon Apr 16, 2012 6:36 am 
Newbie

Joined: Mon Apr 16, 2012 6:07 am
Posts: 1
Hi,

I'm new to Hibernate. I have download the lastest version 4.1.2Final and i'm trying to connect to a Mysql Database.

Please find the sample of code not working :

Code:
try {
   Configuration configuration = new Configuration();
   serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
   factory = configuration.buildSessionFactory(serviceRegistry);
   logger.info("Opening a session");
   Session session = factory.openSession();
   session.close();
   logger.info("Closing session");
   logger.info("Fin du programme principal");
}
catch (Throwable ex) {
   logger.error("Failed to create sessionFactory object." + ex);
   throw new ExceptionInInitializerError(ex);
}


Problem, i'm facing, is the following exception :

Quote:
1297 [main] ERROR Inventory - Failed to create sessionFactory object.org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set
Exception in thread "main" java.lang.ExceptionInInitializerError
at Inventory.main(Inventory.java:31)
Caused by: org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set
at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:97)
at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:67)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:174)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2274)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2270)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1739)
at Inventory.main(Inventory.java:22)


A while ago, i used the class HibernateUtil to get a Session but things have changed with hibernate 4.

Can anyone help me in solving the issue ?

Regards,


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.