'Languages/Groovy'에 해당하는 글 2건

모처럼 그루비 스크립트로 코딩을 하다보니 한글이 깨져서 나왔다.

 

한글깨짐 현상은 어느 언어에서나 나오는 문제이기도 하고, 

대한민국의 개발자라면 참 서럽고 귀찮은 문제가 아닐 수 없다.

 

그래서 찾아봤다.

 

Matthias Bohlen said...

 

set the system property
groovy.source.encoding=UTF-8

 

You can do that on the command line:
export JAVA_OPTS=-Dgroovy.source.encoding=UTF-8

 

Or in Eclipse.ini (if you work with Eclipse)
-Dgroovy.source.encoding=UTF-8

 

Cheers
Matthias

June 22, 2009 4:19 PM

 

이제 됐다.

 

난 이클립스가 아니라 STS를 사용한다.

 

일단 적용 해 보고 콘솔이든 화면이든 한글을 좀 제대로 써 볼 수 있게 되었다.

 

만쉐이!

 

[추가내용]

혹시라도 이클립스나 STS에서 돌릴 때,

별도의 쉘창이나 그루비 전용 콘솔창에서는 한글이 잘 보이는데, STS 하단의 콘솔에서만 한글이 깨지는 경우는

Run > Run Configurations... > 스크립트 파일 선택  후 우측 Common 탭에서

Encoding 다이얼로그 부분을 UTF-8로 설정한다.

 

또는, 개별적으로 설정하기 귀찮다면,

 

Run >> Run Configuration >> application or server(java ee) 선택 >> common 탭 >> console encoding : UTF-8 로 변경, 그리고 Apply~!

 

이것도 적용해 본다.

 

 

 

'Languages > Groovy' 카테고리의 다른 글

Groovy DB 접속 테스트  (0) 2012.07.04

WRITTEN BY
GrimReaper
안녕하세요 Grim Reaper의 티스토리에 오신 것을 환영합니다.

,

1. 목표 : 그루비 스크립트로 아주 간단하게 DB 접속을 해보고자 한다.

2. 방법 : 아주 많이 사용하는 My-SQL과 Oracle 에 각각 접속을 해 본다.

 

먼저 My-SQL ...

 

소스 코드는 아래와 같다

 

import groovy.sql.*;

void testSelect() {
    def url = "jdbc:mysql://localhost:3306/test"
    def username = "사용자명" 
    def passwd = "패스워드"
    def driver = "com.mysql.jdbc.Driver" 
    def sql = groovy.sql.Sql.newInstance(url, username, passwd, driver) 
    def strSql = "select now() as now_date"
    def list = sql.rows(strSql)
	      sql.eachRow(strSql) { row -> println row.now_date}
    // println list
}
testSelect()

 

이번에는 Oracle ...

import groovy.sql.Sql

sql = Sql.newInstance("jdbc:oracle:thin:${아이피}:${포트}:${SID}","아이디"
		,"패스워드","oracle.jdbc.driver.OracleDriver")

rows =[]

sql.eachRow("select to_char(sysdate, 'yyyy-mm-dd, HH24:mi:ss') sys_date from dual"){
	rows << it.toRowResult()
}

rows.each {println rows.sys_date}

 

몇 줄 안되는 코드로 위와 같이 접속 테스트를 진행해 봤다.

 

다음 목표는 인서트, 업데이트..... 기대하시라~!!

'Languages > Groovy' 카테고리의 다른 글

그루비 한글이 깨져나올 때...  (0) 2012.07.05

WRITTEN BY
GrimReaper
안녕하세요 Grim Reaper의 티스토리에 오신 것을 환영합니다.

,