cancel
Showing results for 
Search instead for 
Did you mean: 

how to list the datasource which is configed in visual administration ?

Former Member
0 Kudos

as title as said.thanks in advance.

additional: web dynpro project deployed in ep6.

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

Hi,

1) In your WD add reference to "dbppol" service (right click on WD project->properties->web dynpro references->service references)

2) add <NWDS>\eclipse\plugins\com.sap.tc.ap\comp\SAP-JEE\DCs\sap.com\dbpool\_comp\gen\default\public\default\lib\java\dbpool.jar to class path of your WD project

3) put something like

InitialContext context = new InitialContext();

final DataSourceManager dsm = (DataSourceManager)context.lookup("dbpool");
final Hashtable dataSources = dsm.getDataSources();

final Set entries = dataSources.entrySet();

for (Iterator iter = entries.iterator(); iter.hasNext();) {
	final Map.Entry entry = (Map.Entry) iter.next();
	final JDBCDescriptor desciptor = (JDBCDescriptor)entry.getValue();
	
	wdComponentAPI.getMessageManager().reportSuccess( 		desciptor.getDataSourceName() + ":" + 
		desciptor.getDBConnectInfo() + ":" +
		desciptor.getDriverClassName() + ":" +
		desciptor.getDriverName() + ":" +
		desciptor.getInfo());
}

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

hi,Maksim Rashchynski

thanks for your reply!

but i still met some wrong executed as u said.as following:

1) In your WD add reference to "dbppol" service (right click on WD project->properties->web dynpro references->service references).

<b>=====i opened that directory,and click add button,created a reference named "<u>dbpool</u>",not "<u>sap.com/dbpool</u>",is right?</b>.

2) add <NWDS>\eclipse\plugins\com.sap.tc.ap\comp\SAP-JEE\DCs\sap.com\dbpool\_comp\gen\default\public\default\lib\java\dbpool.jar to class path of your WD project.

<b> =====so pity i cann't find that .jar file.but i can search it under the directory of "usr\sap\J2E\JC00\j2ee\cluster\server0\bin\services\dbpool",so i copy it to the directory of lib of my webdynpro project.and add it to "right click on WD project->properties->java build class->libraries".</b>

step 3 i did as u said.

but a little errors appeared in my web dynpro 'implementation:<u>this compilation unit indirectly references the missing type com.sap.engine.frame.state.managementInterface(typical some required files is referencing a type out the classpath)</u>.

former_member182372
Active Contributor
0 Kudos

Hi,

What is your WAS version?

I have WAS 6.40 SP14 and service name is just "dbpool".

In case of sneak preview jar is located at C:\Program Files\SAP\IDE\IDE70\eclipse\plugins\com.sap.tc.ap_2.0.0\comp\SAP-JEE\DCs\sap.com\dbpool\_comp\gen\default\public\default\lib\java\dbpool.jar

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

sir,

What is your WAS version?

I have WAS 6.40 SP14 and service name is just "dbpool".

==============i user WAS 6.40 sp15

Former Member
0 Kudos

sorry.i check it for again.it was 6.40+sp11.

so faint.

Former Member
0 Kudos

sorry,sir,i upgrade my sp11 to 15,now i can find the dbpool.jar file,i copy it to the lib directory of my web dynpro project.the same error still appeared as my first reply post.

thanks again.

former_member182372
Active Contributor
0 Kudos

Hi,

Try to add "NWDS\JDT\eclipse\plugins\com.sap.tc.ap\comp\SAP-JEE\DCs\sap.com\com.sap.engine.deploy.online\_comp\gen\default\public\default\lib\java\sapj2eenginedeploy.jar" to class path too.

BTW, you don`t need to copy jars to lib folder! In this case jar will be included to WD ear and deployed to WAS. But jar`s are already there and you can face class loading issues (most probably).

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

hi,Maksim Rashchynski:

thanks for u post!

the problem as above is solved as the way of u said.

but web dynpro code cann't excuted correctly.i debug it step by step.

...

<b>final JDBCDescriptor desciptor = (JDBCDescriptor) entry.getValue();</b>

=========cann't go on here.

Looking forward to u reply .

thanks!!

Former Member
0 Kudos

hi,Maksim Rashchynski .

looking forwarding to u reply again.

i need your help.

thanks.

Former Member
0 Kudos

my God.

who can give me a hand?

Former Member
0 Kudos

i cann't solved it!

who can help me?

former_member182372
Active Contributor
0 Kudos

Hi,

What is exactly your problem?

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

hi,Maksim Rashchynski

error as following:

InitialContext context = new InitialContext();

final DataSourceManager dsm = (DataSourceManager)context.lookup("dbpool");

final Hashtable dataSources = dsm.getDataSources();

final Set entries = dataSources.entrySet();

for (Iterator iter = entries.iterator(); iter.hasNext();) {

final Map.Entry entry = (Map.Entry) iter.next();

<u><b>final JDBCDescriptor desciptor = (JDBCDescriptor)entry.getValue();</b></u>

<i>//before everything looked well.debug here step by step ,cann't go on,i don't know what's happened.</i>

......

and: can u tell me how to get the API of DataSourceManager and JDBCDescriptor object.

thanks a lot!

former_member182372
Active Contributor
0 Kudos

Hi,

What does it mean <i>cann't go on</i>? What do you have? ClassCastException? OR <i>descritor</i> is null?

I don`t think such API is available.

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

sorry sir,my english is so poor!

"cann't go on"that means it cann't continue to execute,stoped at there.throw exception is as u said:"<b>java.lang.ClassCastException</b>"

thanks!

former_member182372
Active Contributor
0 Kudos

Hi,

Sorry, my fault. it should be as :

		InitialContext context = new InitialContext();
		
		final DataSourceManager dsm = (DataSourceManager)context.lookup("dbpool");
		final Hashtable dataSources = dsm.getDataSources();
		final Hashtable aliases     = dsm.getAliases();
		final Hashtable drivers     = dsm.getDrivers();
		
		final Set entries = dataSources.entrySet();
		
		for (Iterator iter = entries.iterator(); iter.hasNext();) {
			final Map.Entry entry = (Map.Entry) iter.next();
			final Vector desciptors = (Vector)entry.getValue();
			
			for (Iterator iterator = desciptors.iterator();iterator.hasNext();) {
					final JDBCDescriptor desciptor = (JDBCDescriptor) iterator.next();
			
					wdComponentAPI.getMessageManager().reportSuccess( 	desciptor.getDataSourceName() + ":" + 
																		desciptor.getDBConnectInfo() + ":" +
																		desciptor.getDriverClassName() + ":" +
																		desciptor.getDriverName() + ":" +
																		desciptor.getInfo()
																		);
			}
		}

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

hi,Maksim Rashchynski

now i can get the correct result as u said.

thanks for again!

i 'v gave points to u!

Answers (0)