Hibernate version: 2
Name and version of the database you are using: MySQL
Hi,
I do the following to dynamically set the properties for my database.
I have a property file named hibernate.properties. The variables like
dialect, driver, etc... are certainly not null !
Code:
sessions = new Configuration()
.addClass(Invoice.class)
.addClass(Client.class)
.addClass(Work.class)
.addClass(Day.class)
.addClass(Worker.class)
.setProperty("hibernate.dialect ",dialect)
.setProperty("hibernate.connection.driver_class ",driver)
.setProperty("hibernate.connection.url ",url)
.setProperty("hibernate.connection.username ",username)
.setProperty("hibernate.connection.password ",password)
.setProperty(Environment.HBM2DDL_AUTO, "create")
.buildSessionFactory();
And that's the error I get:
Code:
java.lang.NullPointerException
at java.util.Hashtable.put(Unknown Source)
at java.util.Properties.setProperty(Unknown Source)
at net.sf.hibernate.cfg.Configuration.setProperty(Configuration.java:813)
at storage.HibernateStorage.configure(HibernateStorage.java:84)
at storage.HibernateStorage.<init>(HibernateStorage.java:65)
at control.Control.init(Control.java:52)
at control.Control.main(Control.java:63)
Exception in thread "main"
Is it because I don't use a xml property file, or ...?
Thanks in advance...
Stijn