- 论坛徽章:
- 0
|
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 reference to a factory for java.sql.Connection
jdbc/MySqlDB
javax.sql.DataSource
Container
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.
4. Set the JNDI property in your report to: java:comp/env/jdbc/MySqlDB
![]()
注意:1、开发阶段配置jdbc,直接链接数据库。
2、发布后,如果jdbc和jndi都配置了,会首先寻找jndi。
What is the precedence when both JDBC URL and JNDI name are specified?
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.
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/13625/showart_399384.html |
|