티스토리 뷰

반응형

Informix 데이터베이스에 연결하는 Java 프로그램에서 Informix 오류 메시지가 한글로 표시되는 설정을 테스트 해보았습니다. 그런데 JDBC 드라이버 버전에 따라 오류 메시지가 한글로 보여지지 않는 문제가 있어 공유하고자 합니다.

 

아래는 Informix 서버에 접속하는 테스트를 위한 자바 코드입니다.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConnectionExample {

    public static void main(String[] args) {
        String jdbcClassName="com.informix.jdbc.IfxDriver";
        String url="jdbc:informix-sqli://myhost:1533/testdb:informixserver=myserver;CLIENT_LOCALE=ko_KR.ksc;DB_LOCALE=ko_KR.ksc;IFX_ISOLATION_LEVEL=1";
        String user="informix";
        String password="informix";

        Connection connection = null;
        try {
            //Load class into memory
            Class.forName(jdbcClassName);
            //Establish connection
            connection = DriverManager.getConnection(url, user, password);

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }finally{
            if(connection!=null){
                System.out.println("Connected successfully.");
                try {
                    connection.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

 

한글로 오류 메시지를 표시하려면 아래 두가지 설정이 필요합니다.

ⓛ JDBC 드라이버 구성 파일중 하나인 ifxlang.jar 파일의 전체 경로를 CLASSPATH 환경변수에 추가해야합니다.

② CLIENT_LOCALE 환경변수를 데이터베이스와 일치하는 로케일을 설정합니다.

 

JDBC 드라이버 4.10.JC8 까지는 오류 메시지가 한글로 표시되지만, 4.10.JC9 부터는 설정이 되어있음에도 영문으로 표시되는 것을 우연히 알게 되었습니다.

$ export CLASSPATH=/work/ifmx_jdbc/410jc8/ifxjdbc.jar;/work/ifmx_jdbc/410jc8/ifxlang.jar;.
$ java com.informix.jdbc.Version
IBM Informix JDBC Driver Version 4.10.JC8W1
$ java ConnectionExample
java.sql.SQLException: 트랜잭션을 사용할 수 없습니다.
        at com.informix.util.IfxErrMsg.buildException(IfxErrMsg.java:474)
        at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:443)
        at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:394)
        at com.informix.jdbc.IfxSqli.addException(IfxSqli.java:3191)
        at com.informix.jdbc.IfxSqli.receiveError(IfxSqli.java:3472)
...


$ export CLASSPATH=/work/ifmx_jdbc/410jc9/ifxjdbc.jar;/work/ifmx_jdbc/410jc9/ifxlang.jar;.
$ java com.informix.jdbc.Version
IBM Informix JDBC Driver Version 4.10.JC9W1
$ java ConnectionExample
java.sql.SQLException: Transaction not available.
        at com.informix.util.IfxErrMsg.buildException(IfxErrMsg.java:480)
        at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:449)
        at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:400)
        at com.informix.jdbc.IfxSqli.addException(IfxSqli.java:3193)
        at com.informix.jdbc.IfxSqli.receiveError(IfxSqli.java:3474)
...

 

관련 내용을 IBM에 문의해보니 4.10.JC9 버전 이후부터 오류 메시지가 영문으로만 표시된다는 결함을 확인했습니다.

결함이 수정되기 전까지는 4.10.JC8 버전을 사용해야 할 것으로 보이네요.

 

https://www.ibm.com/docs/en/informix-servers/14.10?topic=formats-support-globalized-error-messages 

 

Support for globalized error messages

Message text is usually the text of an SQLException object, but can also be an SQLWarn object or any other text output from the driver. There are two requirements to enable globalized message text output, as follows: You must add the full path of the ifxla

www.ibm.com

 

반응형
댓글