본문 바로가기
프로그래밍/java

스프링 applicationContext.xml DB connect 접속 설정 예

by RPoint 2012. 10. 8.

<?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:p="http://www.springframework.org/schema/p"

    xmlns:context="http://www.springframework.org/schema/context"

    xmlns:tx="http://www.springframework.org/schema/tx"

    xsi:schemaLocation="http://www.springframework.org/schema/beans

        http://www.springframework.org/schema/beans/spring-beans.xsd

        http://www.springframework.org/schema/context

        http://www.springframework.org/schema/context/spring-context.xsd

        http://www.springframework.org/schema/tx

        http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">


    <context:annotation-config />


    <context:component-scan base-package="prj" />

    <context:component-scan base-package="prj.service" />


    <tx:annotation-driven transaction-manager="transactionManager" />


 

    <!-- 오라클 -->

  <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:@아이피:포트:DB명" />

        <property name="username" value="유저명" />

        <property name="password" value="패스워드" />

        <property name="initialSize" value="5" />

        <property name="maxActive" value="5" />

        <property name="validationQuery" value="SELECT 1 from dual" />

    </bean>




    <!-- ms sql-->

<bean id="dataSourceAAA" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">

   <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>

   <property name="url" value="jdbc:sqlserver://아이피;DatabaseName=DB명"/>

   <property name="username" value="유저명"/>

   <property name="password" value="패스워드"/>

  </bean>


 <!--CUBRID DB-->

  <bean id="dataSourceBBB" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" >

   <property name="driverClassName" value="cubrid.jdbc.driver.CUBRIDDriver"/>

   <property name="url" value="jdbc:CUBRID:아이피:포트:33000:DB명:::"/>

   <property name="username" value="유저명"/>

   <property name="password" value="패스워드"/>

  </bean>


     <!-- transaction manager -->

    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

        <property name="dataSource" ref="dataSource" />


    </bean>


    <bean id="prjDAO" class="prj.dao.prjDAO">

        <property name="dataSource"><ref local="dataSource"/></property>

         <property name="dataSourceAAA"><ref local="dataSourceAAA"/></property>

         <property name="dataSourceBBB"><ref local="dataSourceBBB"/></property>

   </bean>


</beans>

댓글