Zei*_*oun 3 java tomcat jdbc java-8 tomcat8
我正在使用tomcat 7 java 7的项目切换到Java 8 tomcat 8.
我已经重新编译了源代码而没有错误.
我的问题是运行tomcat.
我无法使用此conf连接到资源:
<GlobalNamingResources>
<Resource
name="shared/jdbc/toto"
auth="Container"
type="javax.sql.DataSource"
username="toto"
password="toto"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://syt-db:5432/toto"
maxActive="4"
maxIdle="2"/>
</GlobalNamingResources>
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Cannot load JDBC driver class 'org.postgresql.Driver'
java.lang.ClassNotFoundException: org.postgresql.Driver
Run Code Online (Sandbox Code Playgroud)
我在互联网上的某个地方添加了工厂.
<GlobalNamingResources>
<Resource
name="shared/jdbc/toto"
auth="Container"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
type="javax.sql.DataSourceFactory"
username="toto"
password="toto"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://syt-db:5432/toto"
maxActive="4"
maxIdle="2"/>
</GlobalNamingResources>
Run Code Online (Sandbox Code Playgroud)
并得到这样的错误:
AVERTISSEMENT [localhost-startStop-1] org.apache.naming.NamingContext.lookup Une erreur s est produite durant la résolution de la référence
java.lang.IllegalArgumentException: The local resource link [toto] that refers to global resource [shared/jdbc/toto] does not specify the required attribute type
Run Code Online (Sandbox Code Playgroud)
我觉得现在它可以使用驱动程序但仍然有错误的配置.
我的问题真的来自资源conf还是我应该专注于其他事情?
谢谢
我必须在我的应用程序的上下文中添加type ="javax.sql.DataSource"
<ResourceLink
name="jdbc/toto"
global="shared/jdbc/toto"
type="javax.sql.DataSource"
/>
Run Code Online (Sandbox Code Playgroud)
您需要在ressource定义和server.xml的上下文中编写类型
| 归档时间: |
|
| 查看次数: |
2336 次 |
| 最近记录: |