spring mvc oracle数据源连接问题

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

server.xml

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

context.xml

  1. <WatchedResource>WEB-INF/web.xml</WatchedResource>
  2. <WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
  3. <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
  4. <ResourceLink global="jdbc/vampDS" name="jdbc/vampDS" type="javax.sql.DataSource"/>

web.xml

  1. <resource-ref>
  2. <description>DB Connection</description>
  3. <res-ref-name>jdbc/vampDS</res-ref-name>
  4. <res-type>javax.sql.DataSource</res-type>
  5. <res-auth>Container</res-auth>
  6. </resource-ref>

dispatcher-servlet.xml

  1. <!-- DB -->
  2. <beans:bean id="vampjdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
  3. <property name="dataSource" ref="dataSource" />
  4. </beans:bean>
  5. <beans:bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
  6. <property name="jndiName">
  7. <value>java:comp/env/jdbc/vampDS</value>
  8. </property>
  9. </beans:bean>
  10. <beans:bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" scope="singleton">
  11. <property name="dataSource" ref="dataSource" />
  12. </beans:bean>

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

暂无答案!

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

相关问题