I have a BIRT report which connects to our test database. In the productive environment I would like to supply a datasource which is provided by the container through jndi.
This worked for me. I got the context and from context got the dataSource and passed the connection to Birt report like below
Context initialContext = new InitialContext();
if ( initialContext == null){
System.out.println("JNDI problem. Cannot get InitialContext.");
}
DataSource datasource = (DataSource)initialContext.lookup("java:/datasources/SAMPLE");
task.getAppContext().put("OdaJDBCDriverPassInConnection", datasource.getConnection());