配置全局数据库连接池

在server.xml下

<GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />

    <Resource name="jdbc/webdb" auth="Container"
              type="javax.sql.DataSource"


              driverClassName="com.mysql.jdbc.Driver"

              url = "jdbc:mysql://localhost:3306/数据库名字?charcterEncoding=utf-8"

              username = "root"

              password = "123456"

              maxActive="200"
              maxIdle="50"
              maxWait="3000" />

  </GlobalNamingResources>

apache-tomcat-7.0.73confCatalinalocalhost下建文件夹内容文件名称要与path的值相同

<Context path = "/webdemo" docBase = "webdemo" debug = "0">
    <ResourceLink name = "jdbc/webdb" global = "jdbc/webdb" type="javax.sql.DataSource" />
</Context>
IT文库 » 配置全局数据库连接池
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址