Gentle Breeze
Technical Service <4> DataSource Service 본문
* DataSource Service
AnyFrameJava에서 제공하는 신규 서비스가 아닌 기존의 javax.sql 에 이미 구현 되어있는 Interface 임
- 정의 : DB에 연결하기 위한 Connection 객체를 생성, 안정적 획득, 반납
- 종류
* JdbcDataSourceService (가장 많이 사용)
* DriverManagerDataSource
* JNDIDataSourceService : WAS 서버에 JNDI Naming 서버를 이용할 경우
* DBCPDataSourceService (사용하지 않음)
* C3P0DataSourceService (사용하지 않음)
- 예시 (DriverManagerDataSource)
* xml
<bean id="datasource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource" destroy-method="close">
<property name="driverClassName" value="org.jdbc.driver.OracleDriver"></property>
<property name="url" value="jdbc:oracle:thin@127.0.0.1:1521:xe"></property>
<property name="username" value="hr"></property>
<property name="password" value="hr"></property>
</bean>
* java class
ClassPathXmlApplicationContext ctx =
new ClassPathXmlApplicationContext("classpath*:/spring/datasourceservice.xml");
DataSource datasource = (DataSource) ctx.getBean("datasource");
Connection conn = datasource.getConnection();
if (conn==null)
throw new Exception("fail to get Connection.");
Statement stmt = conn.createStatement();
stmt.executeQuery(
"Insert into users (USER_ID, USER_NAME, PASSWORD) " +
"VALUES ('BBNYDORY', 'BBNYDORY' , 'BBNYDORY')");
'⑦ IFSS 방법론 > IFSS 기초(개발자)' 카테고리의 다른 글
Technical Service <6> Query Service (0) | 2008.10.08 |
---|---|
Technical Service <5> IdGeneration Service (0) | 2008.10.08 |
Technical Service <3> Properties Service (0) | 2008.10.08 |
Technical Service <2> Logging Service (0) | 2008.10.08 |
Technical Service <1> 개요 (0) | 2008.10.08 |