8
Is it possible to bind programatically a DataSource to Tomcat's 6 JNDI?
I want to create a DataSource on the fly and then make it available through JNDI ( to ColdFusion for instance ).
This is what I have:
public void bindToConext(DataSource dataSource) throws NamingException, SQLException {
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
envContext.bind("jdbc/mydatasource", dataSource);
}
But I'm getting this exception:
javax.naming.OperationNotSupportedException: Context is read only
Is there a work around?