How to create jndi datasource in spring boot application

63 Views Asked by At

How to create jndi datasource with the name "jdbc/dblogger" in the springboot application and access inside the custom jar using the code import javax.naming.Context; import javax.naming.InitialContext;

Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
ds = (DataSource) envContext.lookup("jdbc/dblogger");

Iam not able to create this bean.This is my existing datasource code 
    @Bean
    @ConfigurationProperties(prefix = "datasource")
    public DataSource dataSource() {
        return DataSourceBuilder.create().build();
    }
    
 Iam not able to create this bean.This is my existing datasource code .I would like to create another one for jndi datasource with the name "jdbc/dblogger".please help on this.
0

There are 0 best solutions below