1. Install Your JDBC Driver Make an appropriate JDBC driver available to both Tomcat internal classes and to your web application. This is most easily accomplished by installing the driver's JAR file(s) into the $CATALINA_HOME/common/lib directory.
2. Declare Your Resource Requirements
In the webapps/WebViewerExample/WEB-INF/web.xml file, add the following entry to setup your JNDI service:
<resource-ref> <description>Resource reference to a factory for java.sql.Connection</description> <res-ref-name>jdbc/MySqlDB</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref>
where MySqlDB is your JNDI name.
3. Configure Tomcat's Resource Factory
配置数据源请参照
http://www.matrix.org.cn/thread.shtml?forumId=27&topicId=22207
To configure Tomcat's resource factory, add an element like this to the webapps/WebViewerExample/META-INF/context.xml file in the web application.
<Resource name="jdbc/MySqlDB" auth="Container" type="javax.sql.DataSource" maxActive="5" maxIdle="-1" maxWait="10000" username="myuser" password="mypassword" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/classicmodels" description="MySQL Sfdata DB"/>
4. Set the JNDI property in your report to: java:comp/env/jdbc/MySqlDB
If your report design contains a JDBC data source defined with both JDBC Driver URL and JNDI name, then JNDI service will be used first and JDBC driver will be used as fallback. The username and password properties, if specified, are used in both cases. When you need to ensure that JNDI service is really used, increase logging level of BIRT engine; in case of JDBC fallback you will see JNDI lookup errors in the logs.