简体   繁体   English

如何在连接级别以正确格式(CCSID 37)转换IBM DB2十六进制数据,而不使用CAST函数

[英]How to convert IBM DB2 hexadecimal data in proper format (CCSID 37) at connection level without using CAST function

In my application I am having IBM DB2 database as storage and my data service layer has been implemented using Node.js. 在我的应用程序中,我将IBM DB2数据库作为存储,并且我的数据服务层已使用Node.js实现。 I have established JDBC connection to IBM DB2 iSeries database by DataDirect approach given by Progress using db2.jar. 我已使用db2.jar通过Progress给出的DataDirect方法建立了与IBM DB2 iSeries数据库的JDBC连接。 When I execute any select query the result returned from DB is a hexadecimal value not a proper what I want. 当我执行任何选择查询时,从DB返回的结果是十六进制值不是我想要的正确值。 To solve this problem I have an option to use CAST function at query level with each column, but this is not so efficient as I have to apply this CAST in each column so I am trying to have a generic solution at connection level so that I do not have to apply this cast in each column just like "translate binary =true" in JTOpen. 为了解决这个问题,我可以选择在每个列的查询级别使用CAST函数,但这不是很有效,因为我必须在每列中应用此CAST,所以我试图在连接级别使用通用解决方案,以便我不必像JTOpen中的“translate binary = true”那样在每一列中应用此强制转换。

Below are the result with select query - 以下是选择查询的结果 -

Without CAST function :
Query =  SELECT poMast.ORDNO from AMFLIBL.POMAST AS poMast WHERE poMast.ORDNO = 'P544901'
Result in Hex format = D7F5F4F4F9F0F1


With CAST function :
Query = SELECT CAST(poMast.ORDNO CHAR(7) CCSID 37) AS ORDNO from AMFLIBL.POMAST AS poMast WHERE poMast.ORDNO IS NOT NULL
Result in proper format = P544901

Connection URL = "jdbc:datadirect:db2://hostname:port;DatabaseName=dbname;"

Any help will be appreciated. 任何帮助将不胜感激。

may be try to modify your connexionstring like this 可能会尝试像这样修改你的连接字符串

Connection URL = "jdbc:datadirect:db2://hostname:port;DatabaseName=dbname;translate binary=true;ccsid=37"

or like this 或者像这样

Connection URL = "jdbc:db2://hostname:port;DatabaseName=dbname;translate binary=true;ccsid=37"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM