Linux配置Tomcat数据源(DB2)

验证Linux配置Tomcat数据源(DB2)时,数据源的配置如下:

conf\server.xml:

<GlobalNamingResources>

<!– Test entry for demonstration purposes –>
<Environment name=”simpleValue” type=”java.lang.Integer” value=”30″/>

<!– 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 driverClassName=”com.ibm.db2.jcc.DB2Driver” maxActive=”4″ maxIdle=”2″ maxWait=”5000″ name=”DefaultDataSource” password=”131468″ type=”javax.sql.DataSource” url=”jdbc:db2://127.0.0.1:50000/zxdb” username=”db2admin”/>
</GlobalNamingResources>

conf\context.xml:

<Context>

<!– Default set of monitored resources –>
<WatchedResource>WEB-INF/web.xml</WatchedResource>

<!– Uncomment this to disable session persistence across Tomcat restarts –>
<!–
<Manager pathname=”” />
–>
<ResourceLink global=”DefaultDataSource” name=”DefaultDataSource” type=”javax.sql.DataSource”/>
</Context>

异常错误信息如下:

Message: 没有找到名称为 ”{0}” 的数据源.(the datasource with

name ‘default’ cannot get connection!)
at

com.primeton.common.connection.impl.datasource.ext.UnconfirmedD

ataSource.getDataSource(UnconfirmedDataSource.java:83)
at

com.primeton.common.connection.impl.datasource.ext.UnconfirmedD

ataSource.getConnection(UnconfirmedDataSource.java:124)

将db2jcc.jar、db2jcc_license_cisuz.jar、db2jcc_license_cu.jar、jta.jar(解决java.lang.NoClassDefFoundError: javax/transaction/UserTransaction)
4个jar包,放到Tomcat的common\lib目录下,然后重启服务。

     

如果这文章对你有帮助,请扫左上角微信支付-支付宝,给于打赏,以助博客运营

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注