Ich habe Hibernate.cfg.xml-Datei.Hibernate-Konfiguration zur Laufzeit
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url"></property>
<property name="connection.username"></property>
<property name="connection.password"></property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
.....................
Dies ist der interessanteste Teil Datei. Jetzt muss ich fehlende Werte setzen: URL, Benutzername, Passwort. Ich versuche, in einer solchen Art und Weise zu tun:
public static void SetSessionFactory() {
try {
AnnotationConfiguration conf = new AnnotationConfiguration().configure();
// <!-- Database connection settings -->
conf.setProperty("connection.url", URL);
conf.setProperty("connection.username", USERNAME);
conf.setProperty("connection.password", PASSWORD);
SESSION_FACTORY = conf.buildSessionFactory();
} catch (Throwable ex) {
// Log exception!
throw new ExceptionInInitializerError(ex);
}
}
Aber es lädt nur meine Konfiguration von hibernate.cfg.xm und Ändern keine Eigenschaft ...
URL, Benutzername, passoword - sind Befehlszeilenargumente, also muss ich sie auf Runtime setzen.
die Namespace sollte ich verwenden "AnnotationConfiguration" in asp.net MVC zu verwenden? – bluwater2001