'분류 전체보기'에 해당되는 글 43건
- 2023.10.05 lahuman.github.io 를 이용해주세요!
- 2012.09.04 [DB-PRINT]사용법 6
- 2012.07.22 [J-DISTRIBUTE]사용법 1
- 2012.04.23 Shell Programming Tutorial 4
- 2012.04.23 [3장] Spring 에 myBatis 와 Sitemesh 연동 하기 6364
- 2012.04.22 [2장] Spring 을 이용한 Database 및 Transaction Setting 2
- 2012.04.20 [1장] Spring 기본 환경 셋팅 및 Spring-MVC 설정 1
- 2011.09.28 [IMAGE]OPEN IMAGE URL 3
- 2010.09.28 아이폰/아이팟 위치 추적 어플 3
- 2010.06.16 iBatis-Oracle 에서 HashMap 사용시 주의 사항 1
[환경 사항]
- JRE VERSION 1.6 이상
- 환경변수 셋팅 되어 있어야 합니다. (path 에 $JRE_HOME$\bin 추가 되어 있어야 합니다.)
- WINDOWS => 다른 버젼 필요시 연락 주세요.
[지원 DBMS]
- ORACLE
- MYSQL
[지원 OUTPUT 형태]
- HTML
- EXCEL
[다운 로드]
* 압축은 v3 Zip으로 분활 압축 하였습니다.
- JRE 32bit :
- JRE 64bit :
[사용법]
사용법 은 아래와 같이 간단 합니다. DBMS 정보를 입력후에, MAKE OUTPUT 하면 됩니다.
[산출물]
현재 지원 산출물은 html 이며 아래와 같은 표 형식으로 표시 됩니다.
[추후 지원 내역]
- DBMS 추가
- OUTPUT TYPE 추가
[다른 프로그램]
[J-DISTRIBUTE]사용법
* SFTP 연결 추가 하였습니다.
감사합니다.
설치 파일 : 아래 사이트에서 받으세요.
http://lahuman.pe.kr/contents/jdistribute.jsp
오류 신고 및 문의 사항 : lahuman1 골뱅이 gmail.com
라이센스 : 프리웨어
엑셀 파일 양식 :
특이사항 : 특정 폴더 밑에 모든 파일을 업로드/백업 을 하기 위해서는 * 를 이용 하시면 됩니다.
ex) /2012/*
환경변수 셋팅 되어 있어야 합니다. (path 에 $JRE_HOME$\bin 추가 되어 있어야 합니다.)
이상입니다.
http://wiki.kldp.org/wiki.php/ShellProgrammingTutorial
감사합니다.
[1장] Spring 기본 환경 셋팅 및 Spring-MVC 설정
[2장] Spring 을 이용한 Database 및 Transaction Setting
- 목표
Spring 에 myBatis 와 Sitemesh 연동 - 학습
- Default Setting Information
- Add Library
- myBatis 관련
- mybatis-spring - http://code.google.com/p/mybatis/downloads/list?can=3&q=Product%3DSpring
- mybatis -
http://code.google.com/p/mybatis/downloads/list?can=3&q=Product%3DMyBatis
- SiteMesh 관련
- sitemesh Library - https://github.com/sitemesh/sitemesh3/downloads
myBatis 관련 셋팅
mybatis-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- http://groups.google.com/group/ksug/browse_thread/thread/766cd1fd8ba39c96 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!-- mapper file location -->
<property name="mapperLocations" value="classpath:sql/mybatis/mapper/**/*.xml" />
</bean>
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>
</beans>
tesSqlmap.xml - 위치 : sql.mybatis.mapper.test
<?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="kr.pe.lahuman.service.TestDao">
<insert id="insert" parameterType="string" >
INSERT INTO TEST_STR (STR) VALUES( #{str})
</insert>
<delete id="deleteAllData">
DELETE FROM TEST_STR
</delete>
<select id="getList" resultType="java.util.Map">
SELECT str FROM TEST_STR
</select>
</mapper>
TestDao
package kr.pe.lahuman.service;
import java.util.Collection;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
public interface TestDao {
int insert(@Param("str") String str) throws Exception;
void deleteAllData() throws Exception;
Collection<Map<String, String>> getList()throws Exception;
}
* Dao의 실제 구현체는 없다,
사용 법 :
TestServiceImpl
package kr.pe.lahuman.service.impl;
import java.util.Collection;
import java.util.Map;
import kr.pe.lahuman.service.TestService;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class TestServiceImpl implements TestService {
private kr.pe.lahuman.service.TestDao testDao;
@Autowired
public void setSqlSession(SqlSession sqlSession){
// 이부분에서 이렇게 사용 하였으나, 다른 방법도 있음
this.testDao = sqlSession.getMapper(kr.pe.lahuman.service.TestDao.class);
}
@Override
public String getData(String str) throws Exception{
return str;
}
@Override
@Transactional(rollbackFor=Exception.class) //anotation을 사용할 경우
public String insert2Error(String str) throws Exception {
testDao.insert(str);
testDao.insert(str);
testDao.insert(str);
testDao.insert(str);
testDao.insert(str);
testDao.insert(str);
throw new Exception("Insert Error");
}
@Override
public String insert(String str) throws Exception {
return testDao.insert(str)+"";
}
@Override
public Collection<Map<String, String>> getList() throws Exception {
return testDao.getList();
}
@Override
public void deleteAllData() throws Exception {
testDao.deleteAllData();
}
}
sitemesh 관련 셋팅
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>DefaultWeb</display-name>
<!-- sitemesh 관련 추가 사항 -->
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>org.sitemesh.config.ConfigurableSiteMeshFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- sitemesh 관련 추가 사항 -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/config/*-context.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/config/spring-servlet.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
appengine-web.xml
<!-- THIS FILE IS ONLY REQUIRED IF YOU WANT TO DEPLOY TO GOOGLE APP ENGINE. THIS IS NOT NEEDED FOR SITEMESH -->
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>sitemesh-examples-hellowebapp</application>
<version>1</version>
<system-properties>
<property name="file.encoding" value="UTF-8"/>
</system-properties>
<precompilation-enabled>true</precompilation-enabled>
<static-files>
<exclude path="**.html" />
</static-files>
</appengine-web-app>
sitemesh3.xml
<sitemesh>
<mapping path="/*" decorator="/WEB-INF/decorators/master.jsp"/>
</sitemesh>
master.jsp
<html>
<head>
<title>SiteMesh example: <sitemesh:write property='title'>Title goes here</sitemesh:write></title>
<style type='text/css'>
body { font-family: arial, sans-serif; background-color: #ffffcc; }
h1, h2, h3, h4 { text-align: center; background-color: #ccffcc; border-top: 1px solid #66ff66; }
.disclaimer { text-align: center; border-top: 1px solid #cccccc; margin-top: 40px; color: #666666; font-size:10pter; }
</style>
<sitemesh:write property='head'/>
</head>
<body>
<h1 class='title'>SiteMesh example site: <sitemesh:write property='title'>Title goes here</sitemesh:write></h1>
<sitemesh:write property='body'>Body goes here. Blah blah blah.</sitemesh:write>
<div class='disclaimer'>Site disclaimer. This is an example.</div>
<div class='navigation'>
<b>Examples:</b>
[<a href="./">Static example</a>]
[<a href="demo.jsp">Dynamic example</a>]
</div>
</body>
</html>
* 기존에 사용되던 2.x 버전과 달라진 점이 있다 가장 큰것은 파일 명들이 바뀌었다.
기존 decorator.xml => sitemesh3.xml / sitemesh.xml => appengine-web.xml
첨부 파일 :
- 목표
Database 연결과, Transction 을 Setting 과 Test를 한다. - 학습
- Default Setting Information
- Add Library
- commons-dbcp - Database Connection Pool은 DBCP 를 이용한다.
- commons-pool - DBCP를 사용하기 위한 필수 Library
- 접속을 원하는 Database 의 Driver
- aopalliance - Spring AOP를 사용하기 위한 Library
- jakarta-oro - Spring AOP를 사용하기 위한 Library
- com.springsource.org.aspectj.tools - Spring AOP를 사용하기 위한 Library
- Add context
- datasource-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- hsql -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="net.sf.log4jdbc.DriverSpy"/>
<property name="url" value="jdbc:log4jdbc:hsqldb:hsql://localhost/javaworld"/>
<property name="username" value="sa"/>
</bean>
<!-- hsql -->
</beans>
- transaction-context.xml
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<!-- if do you want Annotaion
참조 : http://www.egovframe.org/wiki/doku.php?id=egovframework:rte:psl:transaction:declarative_transaction_management
-->
<tx:annotation-driven transaction-manager="txManager"/>
<!-- if do you want Annotaion -->
<!-- if Method throw Exception, rollback! -->
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="*" rollback-for="Exception"/>
</tx:attributes>
</tx:advice>
<!-- if Method throw Exception, rollback! -->
<!-- Aop setting -->
<aop:config>
<aop:pointcut id="requiredTx"
expression="execution(* kr.pe.lahuman.service.impl.*Impl.*(..))"/>
<aop:advisor advice-ref="txAdvice"
pointcut-ref="requiredTx" />
</aop:config>
<!-- Aop setting -->
</beans>
- 주요 Class
- TestDao
package kr.pe.lahuman.service.impl;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@Repository
public class TestDao {
@Autowired
public void setDataSource(DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource);
}
private JdbcTemplate jdbcTemplate;
public String getData(String str) {
return str;
}
public void deleteAllData(){
this.jdbcTemplate.update(
"delete from test_str");
}
private void insertMethod(String str) {
this.jdbcTemplate.update(
"insert into test_str(str) " +
"values(?)",
str);
}
public String insert(String str) throws Exception{
//insert
insertMethod(str);
return str;
}
public Collection<Map<String, String>> getList()throws Exception{
Collection<Map<String, String>> results = this.jdbcTemplate.query(
"select str from test_str",
new RowMapper() {
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
Map<String, String> map = new HashMap<String, String>();
map.put("str", rs.getString("str"));
return map;
}
});
return results;
}
}
- TestServiceImpl
package kr.pe.lahuman.service.impl;
import java.util.Collection;
import java.util.Map;
import kr.pe.lahuman.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
@Service
public class TestServiceImpl implements TestService {
@Autowired
private TestDao testDao;
@Override
public String getData(String str) throws Exception{
return testDao.getData(str);
}
@Override
@Transactional(rollbackFor=Exception.class) //anotation을 사용할 경우
public String insert2Error(String str) throws Exception {
testDao.insert(str);
testDao.insert(str);
testDao.insert(str);
testDao.insert(str);
testDao.insert(str);
testDao.insert(str);
//강제로 Exception 발생
throw new Exception("Insert Error");
}
@Override
public String insert(String str) throws Exception {
return testDao.insert(str);
}
@Override
public Collection<Map<String, String>> getList() throws Exception {
return testDao.getList();
}
@Override
public void deleteAllData() throws Exception {
testDao.deleteAllData();
}
}
첨부 파일 :
- 목표
Spring Framework 에서 꼭 필요한 Library와 설정 을 알아본다. - 학습
기본적으로 Spring framework를 사용하기 위해서 필요한, 기본 셋팅 정보
- JDK 1.6
- eclipse
- spring framwork
- commons-logging - Spring framework 에서 필수로 필요함
- jakarta-taglibs-standard Spring-MVC 에서 필수로 필요함
web.xml 설정
<!-- Filter Setting -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<!-- Filter Setting -->
<!-- Spring Config Setting -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/config/*-context.xml
</param-value>
</context-param>
<!-- Spring Config Setting -->
<!-- listener Register -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- listener Register -->
<!-- Spring-MVC Config Setting -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/config/spring-servlet.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!-- Spring-MVC Config Setting -->
application-context.xml
<?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"
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-3.1.xsd">
<!-- component scan -->
<context:component-scan base-package="kr.pe.lahuman" >
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!-- component scan -->
</beans>
spring-servlet.xml
<?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:p="http://www.springframework.org/schema/p"
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-3.1.xsd">
<!-- component scan -->
<context:component-scan base-package="kr.pe.lahuman"
use-default-filters="false">
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
<!-- component scan -->
<!--
- This bean configures the 'prefix' and 'suffix' properties of
- InternalResourceViewResolver, which resolves logical view names
- returned by Controllers. For example, a logical view name of "vets"
- will be mapped to "/jsp/vets.jsp".
-->
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver"
p:order="1" p:viewClass="org.springframework.web.servlet.view.JstlView"
p:prefix="/jsp/" p:suffix=".jsp" />
</beans>
TestDao.java
@Repository
public class TestDao {
public String getData(String str){
return str;
}
}
TestServiceImpl.java
@Service
public class TestServiceImpl implements TestService {
@Autowired
private TestDao testDao;
@Override
public String getData(String str) {
return testDao.getData(str);
}
}
TestController.java
@Controller
public class TestController {
@Autowired
private TestService testService;
@RequestMapping(value="/test.do")
public String testView(){
return testService.getData("test");
}
}
첨부파일 참조
iBatis-Oracle 사용시 질의의 결과값을 HashMap 표현으로 가져올 수 있다.
id=”selectItems”
parameterClass=”java.util.Map”
resultClass=”java.util.HashMap”>
select id, name from item where id = #id#
</select>
결과 값은 HashMap에 표현된 키값이 모두 대문자라는 사실이다.
Oracle에서의 질의 결과셋 Meta정보가 그러하다고 한다.
소문자를 주로 사용하는 코딩 환경에서 컬럼명만 대문자로 써줘야 한다는 것은 정말 귀찮은 일이다.
해결 방안
1. resultMap 사용
<select>에다 <resultMap>을 매핑해 주면 가능
(질의 개수만큼 매핑을 만들어 줘야 한다는것)
2. SQL문에서의 해결 방법
select id as “id”, name as “name”..
3. Oracle JDBC Thin Driver를 변경 방법
드라이버 내의 oracle.jdbc.dbaccess.DBColumn 클래스를 수정하면된다.