Eclipse + tomcat中创建数据源(data source)

来源:互联网 发布:unity3d shaderforge 编辑:程序博客网 时间:2024/06/06 20:39

eclipse创建数据源:

在server文件夹下的

1)server.xml的“<GlobalNamingResources>”标签间加入

<Resource 

   name="test"

 auth="Container"

          type="javax.sql.DataSource"

 username="root"

 password="123"

 driverClassName="org.gjt.mm.mysql.Driver"

 maxIdle="10"

 maxWait="15000"

 maxActive="50"  

 url="jdbc:mysql://localhost/test"

 />

2)context.xml的“<Context>”标签中加入:

<ResourceLink global="test" name="test" type="javax.sql.DataSource"/>

3)web.xml的“<web-app>”标签中加入:

<resource-ref>

     <description>DB Connection</description>

     <res-ref-name>test</res-ref-name>

     <res-type>javax.sql.DataSource</res-type>

     <res-auth>Container</res-auth>

</resource-ref>

说明:test 自己取的 ,是创建MySQL链接的名字。

 
 
原创粉丝点击