首页 > 开发 > 综合 > 正文

配置全局数据库连接池

2024-07-21 02:52:59
字体:
来源:转载
供稿:网友

在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.73/conf/Catalina/localhost下建文件夹内容文件名称要与path的值相同

<Context path = "/webdemo" docBase = "webdemo" debug = "0"> <ResourceLink name = "jdbc/webdb" global = "jdbc/webdb" type="javax.sql.DataSource" /></Context>
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表