persistence.properties are database and JPA provider specific.
You can configure a properties (such as database connections) using:
final Properties persistenceProperties = new Properties();
InputStream is = null;
try {
is = getClass().getClassLoader().getResourceAsStream("persistence.properties");
persistenceProperties.load(is);
} finally {
if (is != null) {
try {
is.close();
} catch (IOException ignored) {
}
}
}
entityManagerFactory = Persistence.createEntityManagerFactory("generated", persistenceProperties);
Map props = new HashMap();
props.put(PersistenceUnitProperties.JDBC_USER, "user-name");
props.put(PersistenceUnitProperties.JDBC_PASSWORD, "password");
EntityManagerFactory emf = Persistence.createEntityManagerFactory("pu-name", props);
See : Class PersistenceUnitProperties for a list of all properties.
Most important Hibernate JDBC properties
hibernate.connection.driver_class=oracle.jdbc.OracleDriver
hibernate.connection.url=jdbc:oracle:thin:@//localhost:1521/orcl.HotITem.local
hibernate.connection.username=test
hibernate.connection.password=test
hibernate.hbm2ddl.auto=create-drop
hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider
hibernate.jdbc.batch_size=0
hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
The hbm2ddl.auto property enables automatic generation of database schemas directly into the database.
Note the hibernate.hbm2ddl.auto=create-drop property in the list above instructs Hibernate to initalize the database. This feature is extremely useful for testing as you don't have to take care of the database schema, JPA provider will do it for you. But don't forget to remove this setting from productional configurations or you may loose or corrupt your data if you forget it.
Ter info:
toplink.jdbc.driver=oracle.jdbc.OracleDriver
toplink.jdbc.url=jdbc:oracle:thin:@//localhost:1521/orcl.HotITem.local
toplink.jdbc.user=test
toplink.jdbc.password=test
toplink.ddl-generation=create-tables
toplink.target-database=oracle.toplink.essentials.platform.database.oracle.OraclePlatform
toplink.create-ddl-jdbc-file-name=target/test-database/create.ddl
toplink.drop-ddl-jdbc-file-name=target/test-database/drop.ddl
toplink.logging.level=ALL