I have a scenario where i need to deploy my vaadin application(working fine with multiple databases(2 Persistence units) where runtime is tomcat 7) in SAP HANA Cloud platform(Target runtime is JAVA web).
My earlier database connection was with MYSQL by using eclipselink in below way
private EntityManager getEntityManager(String dbName) {
EntityManagerFactory emf = null;
Map<String, String> properties = new HashMap<String, String>();
if (dbName.toLowerCase().contains("master"))
properties.put(
PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML,
"/META-INF/persistence.xml");
else
properties.put(
PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML,
"/META-INF/persistenceYear.xml");// +dbName.substring(dbName.length()-4)+".xml");
properties.put("javax.persistence.jdbc.driver", getDriver());
properties
.put("javax.persistence.jdbc.url",
getUrl()
+ dbName
+ "?zeroDateTimeBehavior=convertToNull&useUnicode=yes&characterEncoding=utf-8;charset=utf8;characterSetResults=utf8");// &characterSetResults=utf8");
// properties.put("javax.persistence.jdbc.url",
// getUrl()+dbName+"?useUnicode=yes&characterEncoding=UTF-8;characterSetResults=utf8");
properties.put("javax.persistence.jdbc.user", getUserName());
properties.put("javax.persistence.jdbc.password", getPassword());
properties.put(PersistenceUnitProperties.TABLE_CREATION_SUFFIX,
"engine=InnoDB DEFAULT CHARSET=utf8");
properties.put(PersistenceUnitProperties.DDL_GENERATION,
PersistenceUnitProperties.CREATE_OR_EXTEND);
properties.put(PersistenceUnitProperties.DDL_GENERATION_MODE,
PersistenceUnitProperties.DDL_DATABASE_GENERATION);
// properties.put(PersistenceUnitProperties.CREATE_JDBC_DDL_FILE,"create.sql");
// properties.put(PersistenceUnitProperties.APP_LOCATION,
// ServerFolderPathConstants.PROPERTYFILES);
// Configure Session Customizer which will pipe sql file to db before
// DDL Generation runs
// properties.put(PersistenceUnitProperties.SESSION_CUSTOMIZER,
// "in.calico.finbook.config.common.ImportSQL");
// properties.put("import.sql.file",ServerFolderPathConstants.PROPERTYFILES+"create.sql");
try {
/*
* emf = Persistence.createEntityManagerFactory("finbook",
* properties);
*/
emf = Persistence.createEntityManagerFactory(getUnit(), properties);
} catch (Exception e) {
// System.out.println(e.getMessage());
e.printStackTrace();
}
return emf.createEntityManager();
}
Above method helps in connecting to database(MYSQL) and returns entity Manager.
The same methodology i need in my application which is gonna deploy in SAP HANA CLOUD. I want to know how i can get entity managers(multiple databases) and how to create schema's i need to connect?
Please help me.