我的环境是: sql server2000(排序规则:Chinese_PRC_CI_AS)+jdk1.5
触发器如下:
CREATE TRIGGER user_info_update
ON dbo.user_info
FOR update
AS if(update(use_name))
BEGIN
declare @name varchar(100)
declare @str varchar(500)
select @name=user_name from inserted
set @name=rtrim(ltrim(@name))
set @str='d:/ppcService/test.exe '+@name
exec master..xp_cmdshell @str, no_output
END
test.exe是java程序转化成的,为了测试我写了一个简单的信使服务.如下:
public static void main(String[] args) {
try {
String command="net send zhangsan "+getStr(args[0]);
Runtime.getRuntime().exec(command);
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
private static String getStr(String ms){
String str="";
try {
str=new String(ms.getBytes("ISO8859_1"),"GB2312");
} catch (Exception e) {
// TODO: handle exception
}
return str;
}
现在的问题是参数是中文的会出现乱码(数据库中的内容是正常的),更奇怪的是有的中文不会乱,如"心中"能正常显示,但"道德"转换后就是好多问号,有没有朋友遇到过这样的问题?
触发器如下:
CREATE TRIGGER user_info_update
ON dbo.user_info
FOR update
AS if(update(use_name))
BEGIN
declare @name varchar(100)
declare @str varchar(500)
select @name=user_name from inserted
set @name=rtrim(ltrim(@name))
set @str='d:/ppcService/test.exe '+@name
exec master..xp_cmdshell @str, no_output
END
test.exe是java程序转化成的,为了测试我写了一个简单的信使服务.如下:
public static void main(String[] args) {
try {
String command="net send zhangsan "+getStr(args[0]);
Runtime.getRuntime().exec(command);
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
private static String getStr(String ms){
String str="";
try {
str=new String(ms.getBytes("ISO8859_1"),"GB2312");
} catch (Exception e) {
// TODO: handle exception
}
return str;
}
现在的问题是参数是中文的会出现乱码(数据库中的内容是正常的),更奇怪的是有的中文不会乱,如"心中"能正常显示,但"道德"转换后就是好多问号,有没有朋友遇到过这样的问题?
ON dbo.user_info
FOR update
AS if(update(use_name))
BEGIN
declare @name nvarchar(100)
declare @str nvarchar(500)
select @name=user_name from inserted
set @name=rtrim(ltrim(@name))
set @str='d:/ppcService/test.exe '+@name
exec master..xp_cmdshell @str, no_output
END 把里面的 VARCHAR 换成 NVARCHAR 试下