Wednesday, October 17, 2012

连接数据库的时候碰到SQL0332N错误


连接数据库的时候碰到SQL0332N错误:


SQL0332N Character conversion from the source code page "1386" to the target 
code page "819" is not supported. SQLSTATE=57017


创建数据库语句:



db2 "create database apdb ON /apdb_FS using codeset gbk territory CN"



检查发现db2codepage默认819
修改db2codepage=1386
停止并重启实例


db2stop
db2start
db2 connect to apdb




再连接数据库错误依旧。
经过多次研究后发现command line processor没有退出。
退出command line processor


db2 terminate
db2 connect to apdb 





数据库连接成功。

总结:
当碰到这个问题时是因为command line processor在开启时使用的是注册表变量db2codepage来初始化字符集,当重新修改db2codepage时command line processor没有重启导致还是使用了819的页码。所以在修改db2codepage后需要db2 terminate来重启command line processor
注,你可以将command line processor理解成一个数据库连接客户端,如:ibm data studio、QC等。使用客户端连接服务器时必须指定相同或者兼容的页码,否则会出现转换失败的错误。




No comments:

Post a Comment