spring mvc oracle数据源连接问题

dbf7pr2w  于 2021-10-10  发布在  Java
关注(0)|答案(0)|浏览(235)

server.xml

<GlobalNamingResources>
    <Resource name="jdbc/ds" auth="Container" type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
    maxActive="8" maxIdle="4" maxWait="10000" removeAbandoned="true" removeAbandonedTimeout="60" 
    username="admin" password="bookadmin" jdbcInterceptors="ConnectionState;StatementFinalizer" 
    url="jdbc:oracle:thin:@localhost:1524:vampDS/" validationQuery="select 1 " />
</GlobalNamingResources>

context.xml

<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>

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

web.xml

<resource-ref>
        <description>DB Connection</description>
        <res-ref-name>jdbc/vampDS</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>

dispatcher-servlet.xml

<!-- DB --> 
<beans:bean id="vampjdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> 
<property name="dataSource" ref="dataSource" />
</beans:bean>

<beans:bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> 
<property name="jndiName">
<value>java:comp/env/jdbc/vampDS</value>
</property>
</beans:bean>

<beans:bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" scope="singleton"> 
<property name="dataSource" ref="dataSource" />
</beans:bean>

我已经将运行在WebSphereApplicationServer中的应用程序迁移到TomcatWeb服务器。现在我无法从应用程序连接到oracle数据库。这是一个SpringMVC5框架和oracle db版本12。我已经将ojdbc14 jar文件放在tomcat lib文件夹中。放置在tomcat server.xml文件中的db连接字符串。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题