일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
- 한글
- 성능
- DB
- 톰캣
- 자바
- 태그를 입력해 주세요.
- 오류
- miplatform
- java
- 이클립스
- 데이터베이스
- JEUS
- 기타소득
- 마이플랫폼
- Report Designer
- 오라클
- error
- 엑셀
- 함수
- oracle
- Tomcat
- Excel
- MIP
- 도서
- 회계
- 에러
- Eclipse
- Book
- JavaScript
- 튜닝
- Today
- Total
어느 가을날의 전환점
JAVA|JDBC 클라이언트 프로그램에서 NLS_LANG관련 설정 변경하는 방법 본문
JDBC CLIENT PROGRAM 에서 NLS_LANGUAGE , NLS_TERRITORY 등
을 바꾸는 방법을 sample 을 통해서 알아 봅니다.
Explanation
다음 예제에서는 먼저 DB 에 default 로 설정되어 있는
NLS_LANG 관련 설정사항들을 보여주고 그 다음 US 로 설정을
바꾼후에 바뀐 NLS_LANG 관련 parameter 들의 값을 보여 줍니다.
Example
NLSTest.java 파일
import java.sql.*;
import java.util.*;
public class NLSTest {
public static void main (String args []) throws SQLException {
Connection conn;
Statement stmt;
ResultSet rset;
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
System.out.println ("Locale not set");
conn = DriverManager.getConnection ("jdbc:oracle:thin:@krint-5.kr.oracle.com:1525:ora920", "scott", "tiger");
System.out.println();
stmt = conn.createStatement ();
// Get Properties
System.out.println("Java Properties:") ;
System.out.println("property user.language: " + System.getProperty("user.language"));
System.out.println("property user.region: " + System.getProperty("user.region"));
System.out.println();
// Get Locale information
System.out.println("Java Locale:") ;
System.out.println("Locale getDefault = "+Locale.getDefault());
System.out.println("Locale getCountry = "+Locale.getDefault().getCountry());
System.out.println("Locale getLanguage = "+Locale.getDefault().getLanguage());
System.out.println();
// Select the NLS parameters
System.out.println("Current session NLS settings:") ;
rset = stmt.executeQuery ("select * from nls_session_parameters ");
while(rset.next())
System.out.println(rset.getString(1) + " = " + rset.getString(2));
conn.close();
System.out.println();
System.out.println ("Set the default Locale to america");
Locale.setDefault(Locale.US);
conn = DriverManager.getConnection ("jdbc:oracle:thin:@krint-5.kr.oracle.com:1525:ora920", "scott", "tiger");
System.out.println();
stmt = conn.createStatement ();
// Get Properties
System.out.println("Java Properties:") ;
System.out.println("property user.language: " + System.getProperty("user.language"));
System.out.println("property user.region: " + System.getProperty("user.region"));
System.out.println();
// Get Locale information
System.out.println("Java Locale:") ;
System.out.println("Locale getDefault = "+Locale.getDefault());
System.out.println("Locale getCountry = "+Locale.getDefault().getCountry());
System.out.println("Locale getLanguage = "+Locale.getDefault().getLanguage());
System.out.println();
// Select the NLS parameters
System.out.println("Current session NLS settings:") ;
rset = stmt.executeQuery ("select * from nls_session_parameters ");
while(rset.next())
System.out.println(rset.getString(1) + " = " + rset.getString(2));
conn.close();
}
}
실행 결과
E:\temp>java NLSTest
Locale not set
Java Properties:
property user.language: ko
property user.region: KR
Java Locale:
Locale getDefault = ko_KR
Locale getCountry = KR
Locale getLanguage = ko
Current session NLS settings:
NLS_LANGUAGE = KOREAN
NLS_TERRITORY = KOREA
NLS_CURRENCY = ₩
NLS_ISO_CURRENCY = KOREA
NLS_NUMERIC_CHARACTERS = .,
NLS_CALENDAR = GREGORIAN
NLS_DATE_FORMAT = RR/MM/DD
NLS_DATE_LANGUAGE = KOREAN
NLS_SORT = BINARY
NLS_TIME_FORMAT = HH24:MI:SSXFF
NLS_TIMESTAMP_FORMAT = RR/MM/DD HH24:MI:SSXFF
NLS_TIME_TZ_FORMAT = HH24:MI:SSXFF TZR
NLS_TIMESTAMP_TZ_FORMAT = RR/MM/DD HH24:MI:SSXFF TZR
NLS_DUAL_CURRENCY = ₩
NLS_COMP = BINARY
NLS_LENGTH_SEMANTICS = BYTE
NLS_NCHAR_CONV_EXCP = FALSE
Set the default Locale to america
Java Properties:
property user.language: ko
property user.region: KR
Java Locale:
Locale getDefault = en_US
Locale getCountry = US
Locale getLanguage = en
Current session NLS settings:
NLS_LANGUAGE = AMERICAN
NLS_TERRITORY = AMERICA
NLS_CURRENCY = $
NLS_ISO_CURRENCY = AMERICA
NLS_NUMERIC_CHARACTERS = .,
NLS_CALENDAR = GREGORIAN
NLS_DATE_FORMAT = DD-MON-RR
NLS_DATE_LANGUAGE = AMERICAN
NLS_SORT = BINARY
NLS_TIME_FORMAT = HH.MI.SSXFF AM
NLS_TIMESTAMP_FORMAT = DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT = HH.MI.SSXFF AM TZR
NLS_TIMESTAMP_TZ_FORMAT = DD-MON-RR HH.MI.SSXFF AM TZR
NLS_DUAL_CURRENCY = $
NLS_COMP = BINARY
NLS_LENGTH_SEMANTICS = BYTE
NLS_NCHAR_CONV_EXCP = FALSE
E:\temp>
#출처 : http://forums.oracle.com/forums/thread.jspa?threadID=477100&tstart=120
'Database > Oracle' 카테고리의 다른 글
ORACLE|ORA-02085: database link AAAA connects to BBBB (DB Link 오류) (0) | 2011.11.30 |
---|---|
ORACLE|서로 다른 캐릭터셋의 ORACLE DB간 DB_LINK 시 한글 호환 방안(편법?) (0) | 2011.09.07 |
ORACLE|권한(Grant) 자동화 (0) | 2011.08.05 |
ORACLE|Oracle Instant Client (0) | 2011.08.03 |
ORACLE|WITH 구문 (0) | 2011.07.25 |