spring 连接oracle数据库的代码

来源:互联网 发布:io1.1鼠标淘宝哪家最好 编辑:程序博客网 时间:2024/06/05 16:02

用户名和密码要重新填:


<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/aop 
           http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
           http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    <!-- 数据源-->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl" />
<property name="username" value="***" />
<property name="password" value="***" />
<!-- 队列中的最小等待数 -->
<property name="minIdle" value="10"></property>
<!-- 队列中的最大等待数 -->
<property name="maxIdle" value="50"></property>
<!-- 最长等待时间,单位毫秒 -->
<property name="maxWait" value="3000"></property>
<!-- 最大活跃数 -->
<property name="maxActive" value="50"></property>
<property name="initialSize" value="10"></property>
</bean>
    <!-- 数据库连接 --> 
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:myBatis.xml"></property>
</bean>
    <!-- 执行sql语句的工具 -->
    <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
      <constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory" />
    </bean>
   
</beans>
原创粉丝点击