eclipse下tomcat 服務器??怎么配置皕杰數(shù)據(jù)源
數(shù)據(jù)源::本機MySQL中的數(shù)據(jù)庫?test;
服務器:apache-tomcat-6.0.35;
1、先在Eclipse中建立一個Web項目, 我的叫Report。然后在Report項目上集成報表。
2、在\apache-tomcat-6.0.35\conf\Catalina\localhost中,建立名為MyReportJNDI.xml的文件,在其中指明項目路徑和數(shù)據(jù)源配置,內(nèi)容如下:
xml?代碼:
〈Context path="/Report" docBase="D:/java/Report" debug="99" reloadable="true"〉?
〈Resource name="mysql/test" type="javax.sql.DataSource"?
driverClassName="com.mysql.jdbc.Driver" maxIdle="30" maxWait="10000"?
sername="root" password="root"?
url="jdbc:mysql://localhost:3306/test"?
maxActive="100"/〉
〈/Context〉
3、在Report項目的WEB-INF/web.xml 中引用這個數(shù)據(jù)源
xml代碼:
〈resource-env-ref〉
〈description〉Report JNDI〈/description〉??
〈resource-env-ref-name〉mysql/test〈/resource-env-ref-name〉??
〈resource-env-ref-type〉javax.sql.DataSource〈/resource-env-ref-type〉??
〈/resource-env-ref〉
4、在Report項目的WEB-INF\resources\config.xml中設置報表的數(shù)據(jù)源。
在〈dsConf〉 〈/dsConf〉節(jié)點里添加xml代碼:
〈dataSource〉
〈Name〉test〈/Name〈〈!-- 數(shù)據(jù)源名稱,與設計器中一致 --〉
?????〈JNDIPrefix〉java:comp/env/〈/JNDIPrefix〉
?????〈JNDIName〉mysql/test〈/JNDIName〉〈!-- 數(shù)據(jù)源的JNDI資源名稱 --〉
?????〈DBType〉mysql〈/DBType〉
?????〈DBEncode〉gbk〈/DBEncode〉 〈!-- 數(shù)據(jù)庫編碼方式 --〉
〈SQLDecode〉false〈/SQLDecode〉
?????〈Default〉false〈/Default〉
?〈/dataSource〉
注意:數(shù)據(jù)源名稱和數(shù)據(jù)源的JNDI資源名稱是區(qū)分大小寫的。
5、將mysql驅動包mysql-connector-java-5.1.7-bin.jar分別放到apache-tomcat-6.0.35\lib和Report項目WEB-INF\lib下。就這樣,tomcat的數(shù)據(jù)源就創(chuàng)建好了。