cancel
Showing results for 
Search instead for 
Did you mean: 

How know by CODE the dataresource name, from SDM?

roberto_tagliento
Active Contributor
0 Kudos

Usually i do:


		String datasource_name = 
					"jdbc/SAP" + 
						(String) System.getProperties().get("SAPSYSTEMNAME")
								+ "DB";
		String contextUrl = "";
		String contextFactory = "com.sap.engine.services.jndi.InitialContextFactoryImpl";
		Properties properties = new Properties();
		properties.put("java.naming.factory.initial", contextFactory);

		ctx = new InitialContext(properties);
		ds = (DataSource)ctx.lookup(datasource_name);
		con = ds.getConnection();

But sometimes administrator don´t use the rule to put the ResourceName like "SAP is the system ID of SAP instance.

I am developing for DEV environment and have a specific datasource name, but after the track transport i will have for quality environment another datasource name, and the same will happen for production.

Any idea on how to realize a flexible solution CODE that can work for all environment?

Accepted Solutions (0)

Answers (1)

Answers (1)

roberto_tagliento
Active Contributor
0 Kudos

If i use application properties, and deploy my project, make all transport AFTER via web, from WebDynpro content i can change the properties???

former_member182294
Active Contributor
0 Kudos

Hi Roberto,

You can pass the DB name as URL parameter. Any ways the Web Dynpro application will be an iView in the portal. You can set the parameter when you configure the iView or you can pass as dynamic parameter. Like this you can change the parameter any time you required. By using the following code you can read the parameter -

WDWebContextAdapter.getWebContextAdapter().getRequestParameter("dbname");

Regards

Abhilash

roberto_tagliento
Active Contributor
0 Kudos

Good idea!

Any one other can tell me something?

Former Member
roberto_tagliento
Active Contributor
0 Kudos

Thanks Mukesh

i will study this pages.