Tuesday, May 10, 2005

CLI0125E Exception ใน WebSphere

สืบเนื่องมาจากการย้าย Application server
จาก Aix ขึ้นไปบน Linux Mainframe

ผลการทดสอบ ปรากฎว่าพบปัญหา
[9/5/2005, 16:25:13:275 ICT] 3d24ec3d SystemOut     O 16:25:13,273 ERROR [UnEmpl
   oyInfoFindCmd] COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] CLI0125E Functi
   on sequence error. SQLSTATE=HY010
   COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] CLI0125E Function sequence err
   or. SQLSTATE=HY010
    at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(SQLExce
   ptionGenerator.java:273


ก็เลยต้องไปใล่ค้นใน net ดู
ปรากฎว่าเป็นปัญหาประเภทว่า
เรา select ค่ามาใส่ result set (cursor เปิดอยู่)
จากนั้นเราก็ iterate ไปตาม result
โดยใช้ rs.next()
โดยแต่ละค่าที่ iterate จะมีการเปิด statement
ใหม่เพื่อที่จะ select ค่า (จากอีก table หนึ่ง)
ตรงนี้แหล่ะที่เป็นปัญหา
เข้าใจว่า พอเราทำอีก statement หนึ่ง
ตัว cursor ก็จะปิดไป ทำให้พอ iterate
ไปยัง result ตัวถัดไป ก็จะเกิด Exception นี้ขึ้น

ทางแก้ไข
ต้องเข้าไป set datasource property

    Name: connectionAttribute
    Type: java.lang.String
    Value: cursorhold=1


ประเด็นที่น่าสนใจ
ทำไมใน Aix ไม่ต้อง set ก็ run ได้

อ้างอิง
To resolve a CLI0125E error, can I set the CURSORHOLD property to 1 (TRUE) for a DB2 V8.1 datasource (using WebSphere Application Server V5.0.2), as is recommended for a DB2 V7.1 datasource in earlier versions of WebSphere?
A: Yes, this solution is still valid for WebSphere Application Server V5.0.2 and a DB2 V8.1 datasource.

The performance ramifications of this setting are minimal. Currently, if the transaction is completed or closed, the cursors are not destroyed in the memory. However, they are destroyed when a specific CLOSE CURSOR is issued. Therefore, if your code follows good programming practices (that is, OPEN a cursor, FETCH rows, CLOSE cursor), and if the code does the CLOSE CURSOR for every OPEN CURSOR, then setting the CURSORHOLD property should not be a performance concern.

Related link from Roti

No comments: