Manuelle Konfiguration von Hibernate im Programmcode

Status
Nicht offen für weitere Antworten.

sparrow

Top Contributor
Hallo Forum,

ich möchte in einem Projekt Hibernate einsetzen, jedoch auf die hibernate.cfg.xml verzichten.
Mein Projekt hat sowieso eine ganz normale Konfigurationsdatei.

Nun habe ich folgendes Versucht:
Code:
AnnotationConfiguration configuration = new AnnotationConfiguration();
Properties props = new Properties();
props.setProperty("connection.driver_class", driver);
props.setProperty("connection.url", url);
props.setProperty("connection.username", user);
props.setProperty("connection.password", pass);
props.setProperty("hibernate.dialect", dialect);
props.setProperty("hibernate.hbm2ddl.auto", "update");
configuration.setProperties(props);
configuration.buildSettings();
configuration.buildSessionFactory();

Funktioniert aber leider nicht.

Als Fehler erhalte ich: The user must supply a JDBC connection.


Ich vermute, dass er die Properties die mit connection beginnen nicht übernimmt.
Weiss jemand wie ich die im Programm setze?


Gruß
Sparrow
 
Moah... danke SlaterB....
manchmal sieht man den Wald vor lauter Bäumen nicht.
Mit einem hibernate. vorweg funktioniert es!

Vielen Dank!
 
Status
Nicht offen für weitere Antworten.

Neue Themen


Zurück
Oben