tomcat6配置jndi連接數據庫的方式

eworkflow工作流+eform表單+ebiao報表集成在一起,用tomcat6發佈,並用jndi連接數據庫,數據庫是sqlserver2005,配置如下:

 

1、在tomcat6\conf\context.xml文件的Context節點中增加下面節點:

<Resource name="jdbc/eworkflow" auth="Container" type="javax.sql.DataSource" username="sa" password="" driverClassName="net.sourceforge.jtds.jdbc.Driver" url="jdbc:jtds:sqlserver://localhost:1433;databaseName=eworkflow-java;integratedSecurity=true;" maxActive="100" maxIdle="30" maxWait="10000"/>

 

2、方成軟件web-inf\fcconfig.xml文件中第一個ds節點配置如下:

<ds name="eworkflow" dbType="sqlserver" type="jndi" jndiName="jdbc/eworkflow" jndiPrefix="java:/comp/env" />

 

3、web-inf\web.xml文件中web-app節點中增加下面節點:

<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/eworkflow</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

 

4、通過數據源訪問數據庫,由於數據源由tomcat創建並維護,所以必須把數據庫連接驅動包複製到tomcat的lib目錄下。

  這裏把jtds-1.2.jar複製到tomcat\lib目錄中。

 

 

啓動 tomcat6,在瀏覽器中輸入:http://localhost:8080/ebiao,登錄系統。

發佈了8 篇原創文章 · 獲贊 1 · 訪問量 7283
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章