<!-- DataSource 설정하기 -->
<context:property-placeholder location="classpath:config/database.properties" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<!-- Mybatis 설정하기 -->
<bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:test-map-Config.xml" />
</bean>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd" >
<configuration>
<typeAliases>
<typeAlias type="com.psd.biz.member.common.PsdVo" alias="PsdVo" />
</typeAliases>
<mappers>
<mapper resource="mappings/board-mapping.xml" />
</mappers>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="psdDAO">
<insert id="insertBoard">
<![CDATA[
insert into table_psd (idx, name, fname)
values (table_sq.NEXTVAL, #{name} , #{fname})
]]>
</insert>
<delete id="deleteBoard">
<![CDATA[
delete from table_psd where idx = #{idx}
]]>
</delete>
<select id="selectAll">
SELECT *
FROM TABLE_PSD
ORDER BY IDX DESC
</select>
<select id="delete_name">
SELECT FNAME
FROM TABLE_PSD
WHERE IDX = #{idx}
</select>
<update id="updateBoard">
UPDATE TABLE_PSD
SET NAME = #{name}
WHERE IDX = #{idx}
</update>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="psdDAO">
<insert id="insertBoard" parameterType="com.psd.biz.member.common.PsdVo">
<![CDATA[
INSERT INTO TABLE_PSD (IDX, NAME, FNAME)
VALUES (table_sq.NEXTVAL, #{name} , #{fname})
]]>
</insert>
</mapper>
@Repository
public class MybatisDAOImpl extends SqlSessionDaoSupport implements PsdDAO {
@Autowired
public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
super.setSqlSessionFactory(sqlSessionFactory);
}
@Override
public void insert(PsdVo vo) {
getSqlSession().insert("psdDAO.insertBoard", vo);
}
}