Document Type | Troubleshooting
Category | Interface/Integration
Applicable Product Version | 6FS07, 6FS07PS
Document Number | TIITS006
Issue
When calling a Tibero procedure from Tomcat, the return value of the TO_CHAR(TO_DATE(column_name, 'YYYYMMDD'), 'DY') function is processed differently depending on the language setting, which can cause a division by zero during calculation, resulting in the error below.
- Error Code: ERROR_NUMBER_DIVIDE_BY_ZERO(-5070)
- Occurrence Timing: When calling a procedure including the TO_CHAR(..., 'DY') function from Tomcat
This error occurs when a division operation is performed with a numeric column value of zero. If the encoding between Tomcat and Tibero does not match and Tomcat does not specify the default encoding setting, the day name is processed in English.
Cause
Because Tomcat's default encoding value is English (EN), when using the TO_CHAR(YYYYMMDD,'DY') function, the day name is returned in English. Therefore, if the expected value in Tibero (Korean - "์") does not match the returned value, an error occurs during calculation in the procedure execution.
- Tomcat Result: English day names such as "MON", "TUE"
- Tibero CLI Result: Korean day names such as "์", "ํ"
If the encoding differs, abnormal calculation processing can occur, resulting in zero being calculated and causing ERROR_NUMBER_DIVIDE_BY_ZERO.
Solutions
Modify the Tomcat encoding setting to Korean so that the day names match when running Tomcat.
1. Add the following encoding settings to Tomcat Config
-Duser.language=ko -Duser.country=KR -Dfile.encoding=UTF-8"
2. Restart Tomcat
$ systemctl restart tomcat
Test Scenario
1. Before setting encoding in Tomcat, call the procedure from Tomcat to get the day name for a specific date.
SQL> select * from Day_ck; DD ---------- MON
2. After setting encoding in Tomcat, call the procedure from Tomcat to get the day name for a specific date.
SQL> select * from Day_ck; DD '---------- ์
Test Details
1. Create procedure and table.
Create log table SQL> CREATE TABLE DAY_CK (DD VARCHAR2(10));
Create procedure CREATE OR REPLACE PROCEDURE SYSDATE_COUNT( AutoDate IN VARCHAR2 ) IS TEMP VARCHAR(8); BEGIN TEMP := TO_CHAR(TO_DATE(AutoDate,'YYYYMMDD'),'DY'); INSERT INTO DAY_CK(DD) VALUES(TEMP); COMMIT; END; /
2. Call the procedure in the DB.
SQL> call SYSDATE_COUNT(20240822);
Check the result below.
SQL> select * from Day_ck; DD '---------- ๋ชฉ
3. Call the procedure from Tomcat.
try{
conn = DriverManager.getConnection(dbURL,username,password);
out.println("Tibero Database connection successful!");
cs = conn.prepareCall("CALL SYSDATE_COUNT(?)");
cs.setString(1,"20240701");
cs.executeQuery();
... omitted ... SQL> select * from Day_ck; DD ---------- MON