on 11-13-2012 2:15 PM
We are using JPA. If we want to debug, we need to do this on the Local SAP NetWeaver Cloud server. When running on the local server, we currently comment out this line - which we need when running on SAP NetWeaver Cloud. One idea was to find out in our coding on which server we are running.
1. Is there a way to get this information?
2. Is there a better way to run the code on the local SAP NetWeaver Cloud without changing the coding?
Thanks Frank
entityManagerProperties.put(
"eclipselink.target-database", "com.sap.persistence.platform.database.HDBPlatform");
Hi Frank,
asuming you want to know which DB platform your code is running against you might want to try a code snippet that is used in our tutorial Adding Persistence Using JPA (SDK 1.x) (https://help.netweaver.ondemand.com/default.htm?add_persistence_neo.html#concept_BE64823733A746719F6...) in the init()
method of class PersistenceWithJPAServlet
:
try {
InitialContext ctx = new InitialContext();
ds = (DataSource) ctx.lookup("java:comp/env/jdbc/DefaultDB");
Map properties = new HashMap();
properties.put(PersistenceUnitProperties.NON_JTA_DATASOURCE, ds);
String databaseProductName = ds.getConnection().getMetaData()
.getDatabaseProductName();
if (databaseProductName.equals("HDB")) {
properties.put("eclipselink.target-database",
"com.sap.persistence.platform.database.HDBPlatform");
}
emf = Persistence.createEntityManagerFactory(
"persistence-with-jpa", properties);
} catch (NamingException e) {
throw new ServletException(e);
} catch (SQLException e) {
LOGGER.error("Could not determine database product.");
throw new ServletException(e);
}
Best Regards,
Bernd
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.