0

As we all know we can get a data-source reference or any JNDI reference from server using InitialContextFactory

Ex. When it comes to Websphere Application Server using below properties we can get reference: com.ibm.websphere.naming.WsnInitialContextFactory corbaloc:iiop:localhost:2809

The InitialContextFactory varies based on server instance you are using.

Question:

While configuring spring data source or JNDI we dont provide server details ( like name of server, type .. etc) and in which port corbaloc running.

If I really write my own program to get data-source then I have to know above details to get but

How Spring code is so generic and without knowing those details how it is getting JNDI reference?

thanks for your answers..

  • For xml configuration have a look at https://stackoverflow.com/questions/9183321/how-to-use-jndi-datasource-provided-by-tomcat-in-spring, for java code configuration https://stackoverflow.com/questions/34757609/how-to-convert-jndi-lookup-from-xml-to-java-config – Ralph Jun 19 '17 at 08:20
  • (for java code based configuration you do not need `@Value("${db.jndi}" String jndiName` for the example, replace the variable `jndiName` with an constant) – Ralph Jun 19 '17 at 08:25

0 Answers0