cancel
Showing results for 
Search instead for 
Did you mean: 

How to I find out where my code is running?

frank_albrecht
Advisor
Advisor
0 Kudos

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");

Accepted Solutions (1)

Accepted Solutions (1)

bernd_hofmann
Active Participant
0 Kudos

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

Answers (0)