SSI (Struts 2 + Spring 2.5 + Ibatis. 2.16) 프레임 워 크 의 데이터 원본 설정.

3012 단어 struts2
최근 SSI 프레임 워 크 를 사용 할 때 데이터 원본 연결 풀 이 필요 한 방식 을 사용 합 니 다.
일반적으로 데이터 원본 을 설정 하 는 방법 은 여러 가지 가 있 습 니 다. 어떤 것 이 더 적합 한 작업 을 해 야 하 는 지 보 세 요.
 
다음은 우리 가 작업 할 때 사용 하 는 데이터 원본 설정 절 차 를 말씀 드 리 겠 습 니 다.
 
1>> spring 의 applicationContext. xml 파일 에 데이터 원본 설정:
    다음은 ibatis 의 sqlMapClient 설정 입 니 다.
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
	<property name="configLocation" value="classpath:sql-map-config.xml" />
	<property name="dataSource" ref="DataSource" />
	<property name="useTransactionAwareDataSource" value="true"></property>
</bean>
	
<bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
	<property name="sqlMapClient">
		<ref bean="sqlMapClient" />
	</property>
</bean>

   데이터 원본 설정.
 
<bean id="DataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> 
	<property name="jndiName" value="java:comp/env/jdbc/datasource"></property>
</bean>

 
 
2 > > 두 번 째 단 계 는 웹. xml 프로필 에 tomcat 에서 설정 한 데이터 원본 을 적용 합 니 다. (데이터 원본 의 참조 이름 을 주의 하 십시오. tomcat 와 같 아야 합 니 다. 그렇지 않 으 면 데이터 원본 정 보 를 찾 을 수 없습니다.)
<resource-ref>
	<description>datasource</description>
	<res-ref-name>jdbc/datasource</res-ref-name>
	<res-type>javax.sql.DataSource</res-type>
	<res-auth>Container</res-auth>
</resource-ref>

 
3 > > 세 번 째 단 계 는 구체 적 인 용기 에 데이터 원본 을 설정 합 니 다. 이 예 는 tomcat - 6.0.29 와 websphere 두 가지 방식 으로 예 를 들 어 설명 합 니 다.
먼저 tomcat 를 디스크 에 압축 을 풀 고 있 습 니 다. 예 를 들 어 다음 과 같은 위치 입 니 다.
D:\apache-tomcat-6.0.29\apache-tomcat-6.0.29\conf
conf 디 렉 터 리 에서 context. xml 프로필 을 찾 습 니 다:
다음 내용 설정: ()
<?xml version='1.0' encoding='utf-8'?>
<!-- The contents of this file will be loaded for each web application -->
<Context>

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    
<!-- b.Oracle 10g  -->
<Resource name="jdbc/datasource" 
            auth="Container"
            type="javax.sql.DataSource" 
            username="scott" 
            password="tiger"
            driverClassName="oracle.jdbc.driver.OracleDriver" 
            url="jdbc:oracle:thin:@192.168.1.100:1521:ORCL"
            maxActive="100" 
            maxIdle="10"/> 
</Context>

좋은 웹페이지 즐겨찾기