티스토리 뷰
* groovy ?
잘알려진(well- known) 한 언어들은 대부분 여러이유로 스크립트 언어를 가지고 있다
그 이유는 성능, 보안 , 사용상의 간편함 등등 다양할것이다 (장점에 대비되는 단점도 많다)
그루비라는 언어는 사실 얼마 되지않은 언어이지만 한때 붐을 일으켰다가 지금은 서서히...여튼 그렇다
인사이트에서 나온 그루비 한글 서적은 절판되어 더이상 나오지 않지만 ( 인사이트의 실패작이라고 스스로 자책하던데)
미국 사이트들에선 무료 e-book 을 구할수 있으니 찾아보길 권유한다
또한 드문드문 공식홈에서 한글페이지도 제공하고 있으니 공부하기엔 어렵지 않을 것같다
* http://springsource.tistory.com/85
* http://groovy.codehaus.org/Korean+Groovy+SOAP
* sql on groovy console
아직은 지식이 미천하여 많은 내용을 쓰진 못하지만
최근에 atlassian 이라는 호주회사에서 쓰는 jira 라는 time tracking system (엔터프라이즈 비즈니스 시스템) 이 있는데
<jira 를 tts 시스템으로 한정하기엔 많은 기능이 있지만 예를 들어>
이곳에서 지원하는 groovy console 로 sql 을 작성할 기회가 있었다
여러곳에서 쓰는 jira 인만큼 많은 forum 을 가지고 있는데 대다수의 내용은 그곳에서 보고 배껴낸것들이다
* select
execute a sql query 를 그대로 배껴서 내용만 변경하면 내용을 볼수 있다
https://jamieechlin.atlassian.net/wiki/display/GRV/Miscellaneous+Groovy+Scripts
* delete, update, insert 등
import com.atlassian.jira.ComponentManager
import groovy.sql.Sql
import java.sql.Connection
import org.ofbiz.core.entity.ConnectionFactory
import org.ofbiz.core.entity.DelegatorInterface
ComponentManager componentManager = ComponentManager.getInstance()
delegator = (DelegatorInterface) componentManager.getComponentInstanceOfType(DelegatorInterface.class)
String helperName = delegator.getGroupHelperName("default");
def sqlStmt = """
delete from cwd_user
where active ='0'
"""
Connection conn = ConnectionFactory.getConnection(helperName);
Sql sql = new Sql(conn)
sql.executeUpdate(sqlStmt)
Run now |
버튼을 누르면 실행된 결과의 행갯수가(ex. result 2400) 나오게 된다
뭔가쓰고보니 어설프고 애매한부분이 많긴하다
다듬을 기회가 있으면 다듬어야겠다