Java读tpkg文件中文乱码_jolt乱码问题

jolt乱码问题

2013/7/23 18:40:25  heqinghua  程序员俱乐部  我要评论(0)

摘要:这个破问题困扰了我两天,今天终于搞定了,还是那句话,要坚信,bug的毅力永远比不过你。解决方法1、添加全局环境变量:JOLTI18N=TRUE(环境变量改如何添加,我就不做描述了JOLTI18N是name,TRUE是value)2、在java项目中导入包jolti18n.jar这个包可以在tuxedo的安装目录中找到。3、在java代码中,添加一句代码:System.setProperty("bea.jolt.encoding","iso8859_1");,这句代码就添加在服务定义之前

这个破问题困扰了我两天,今天终于搞定了,还是那句话,要坚信,bug的毅力永远比不过你。

解决方法

1、添加全局环境变量:

JOLTI18N=TRUE

(环境变量改如何添加,我就不做描述了JOLTI18N是name,TRUE是value)

2、在java项目中导入包jolti18n.jar  这个包可以在tuxedo的安装目录中找到。

3、在java代码中,添加一句代码:System.setProperty("bea.jolt.encoding", "iso8859_1");

,这句代码就添加在 服务定义之前,具体看我代码:(一下代码中红色部分就是添加的内容)

这里稍微说明下:iso8859_1这是个变量,根据你自己的项目编码设定,如果iso8859_1依然是乱码,可以修改成utf-8,或则是GBK。

public  void monitorSbjTuxedo(String serviceName, String inStr, String ServiceIP, int ServicePort) throws Exception {

System.setProperty("bea.jolt.encoding", "iso8859_1");

JoltSession session = null;

JoltSessionAttributes sattr = null;

JoltRemoteService toupper = null;

String userName = null;

String userPassword = null;

String appPassword = null;

String userRole = null;

String returnData = null;

if (serviceName == null)

throw new Exception("调用平台服务错误:传入的服务名为空");

try

{

sattr = new JoltSessionAttributes();

sattr.setString("APPADDRESS", "//" + ServiceIP + ":" + ServicePort);

sattr.setInt("IDLETIMEOUT", 1800);

session = new JoltSession(sattr, userName, userRole, userPassword, appPassword);

toupper = new JoltRemoteService(serviceName, session);

toupper.addString("STRING",  new String (inStr.getBytes("GBK"), "iso8859_1"));

toupper.call(null);

returnData = new String ( toupper.getStringDef("STRING", "").getBytes("iso8859_1"), "GBK");

}

catch (Exception ex) {

throw new Exception(ex.getMessage() + "调用平台服务出错");

}

toupper.clear();

session.endSession();

sattr.clear();

toupper = null;

session = null;

sattr = null;

}

1、说明(因为我也怀疑过配置文件是否需要修改,这里声明下,配置文件不需要任何更改)

jrepository配置文件中的代码基本不用变

/home/tuxedo/bea/tuxedo11gR1/udataobj/jolt/repository

我没有做任何改动,还是原来的

add SVC/TOLOWER:vs=1:bt=STRING:BT=STRING:ex=1:bp:pn=STRING:pt=string:pf=167772161:pa=rw:ep:

add PKG/BULKPKG:TOLOWER:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值