PDA

View Full Version : How to use JNDI url of BIRT



intellect
11-23-2006, 05:42 AM
Im working in BIRT now. I have to use a same data source for all reports that i generate.If i change the database name or username or password it should reflect in all reports.

I used the xml datasource.But it is asking the report parameters every time for drivername, username,etc.., I want to use the JNDI url. I dont know how to use this. What value should i give in the JNDI url field in new data source. Please guide me how to use the JNDI url. I have no idea about it.So please guide me in detailed manner.

mbatchelor
11-25-2006, 09:21 PM
Sorry, but BIRT doesn't support JNDI. The JFreeReport component however does. I suggest you try to duplicate your reports using either the Report Design Wizard (simple reports) or the Report Designer (more complex layouts).

Take care,

Marc

intellect
11-27-2006, 05:30 AM
But ,im using the BIRT2.1.1. In that whilw we create a datasource there is an option name JNDI url. What is the use of it? Could u please tell me?

davidl
08-14-2008, 02:42 PM
BIRT 2.1 and up does support JNDI, see:

http://www.eclipse.org/birt/phoenix/project/notable2.1.php#jump_4

We've been using JNDI from BIRT a different way: we have scripted data-sources backed by Java classes for some of our BIRT reports, and each data-source takes a parameter for a JDBC URL to use. If that parameter is not specified, it looks up a connection in JNDI. The code to do that is really simple:


try {
Context ctx = new InitialContext();
DataSource dsrc = (DataSource) ctx.lookup( "java:/SampleData" );
con = dsrc.getConnection();
} catch (NamingException ex) {
No other configuration is needed; it just picks up a pooled connection from JBoss.

sggago
10-23-2008, 07:37 AM
We are using 2.2.2 version.
Suposing we can only use JNDI data source, where must i add that piece of code, into a report element or adding to an specific or a preexisting java class?

jashaffner
10-29-2008, 01:51 PM
I just now was able to use jndi for birt reports.

This is what I did.

1. drop driver jar (jtds.jar in my case) in tomcat/common/lib.
2. add a resource either in tomcat/conf/context.xml or tomcat/webapps/pentaho/META-INF/context.xml


<Resource
name="jdbc/fooDB"
auth="Container"
type="javax.sql.DataSource"
driverClassName="net.sourceforge.jtds.jdbc.Driver"
url="jdbc:jtds:sqlserver://<server_addy)/<db_name>"
username="****"
password="****"
maxActive="20"
/>

3. set jndi property in report


java:comp/env/jdbc/fooDB

references:
http://wiki.eclipse.org/index.php/BIRT/FAQ/Data_Access
https://bugs.eclipse.org/bugs/show_bug.cgi?id=131662#c7
http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html