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

eworkflow工做流+eform表單+ebiao報表集成在一塊兒,用tomcat6發佈,並用jndi鏈接數據庫,數據庫是sqlserver2005,配置以下:java

 

一、在tomcat6\conf\context.xml文件的Context節點中增長下面節點:web

<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"/>sql

 

二、方成軟件web-inf\fcconfig.xml文件中第一個ds節點配置以下:數據庫

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

 

三、web-inf\web.xml文件中web-app節點中增長下面節點:tomcat

   <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>app

 

 四、經過數據源訪問數據庫,因爲數據源由tomcat建立並維護,因此必須把數據庫鏈接驅動包複製到tomcat的lib目錄下。sqlserver

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

 

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

相關文章
相關標籤/搜索