Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jndi lookup  RSS feed

 
anvi kon
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am getting the data source like below.


I want to know the name of the datasource(for example here EmpDODS)


Do we have any method to get the datasource name like getDataSourceName() which returns a name.?

Thanks
 
Deepak Pant
Ranch Hand
Posts: 446
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it is possible to get the name. Try this.

1. Call listBindings(String name) method on the InitialContext object, which will return NamingEnumeration<Binding> object.

2. Iterate thru the enumeration and call getName() method of the Binding object.

3. Since your binding name would be unique, you will get one item in the enumeration for the datasource.
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak Pant wrote:Yes it is possible to get the name. Try this.

1. Call listBindings(String name) method on the InitialContext object, which will return NamingEnumeration<Binding> object.

2. Iterate thru the enumeration and call getName() method of the Binding object.




That would return the jndi-name to which the datasource is bound. I don't know whether the original poster is actually looking for that information. A DataSource in itself does not have any name associated with it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!