![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
#4
| |||
| |||
|
|
Hi, I am having trouble using a DB2 Express-C DB on a Linux Server from the server itself in an Application (VA Smalltalk). The trouble is that my application doesn't handle utf-8 correctly, so I need the DB to talk ISO-8859-15 to my application. One thing I figured out is that I can create the database using codeset ISO-8859-15 territory DE. So far this works very well in combination with a windows based client, which is set to German in Windows. So the client uses the correct codepage and codeset. There was nothing I had to do on that Windows client. But now I need to move the application to a Linux server (the one where the DB server is installed on), and I am lost in getting this application configured to connect to the DB using a codeset other than utf-8. Maybe my main problem is that I haven't found out at what level I need tochange the codepage/codeset: * In the user environment that starts teh Application (I tried by doing an export LANG=de_DE.iso8859-15 with no success. The app itself handles Umlauts correctly, but gets wrong results from the DB) * In the environment of the instance owner (e.g. by setting LANG in .profile) * By setting DB2CODEPAGE as Instance Owner (and if that is the solution, what exact value would I use for DB2CODEPAGE - I tried db2set DB2CODEPAGE=ISO-8859-15, but other than db2set telling me it is set to that value, nothing changes, even after a restart of the server) calling db2 -a connect to db xxx always claims that the client codepage is 1208. But that's utf-8... So I was hoping somebody can help me see the trees somewhere in the forest... I tried understanding that stuff in the db2 information center, but seem to be missing some detail Thank you in advance, Joachim |
#5
| |||
| |||
|
|
It really was that easy. So after searching a bit more (I guess I already had searched too long and found too many bits of information that I couldn't sort any more) I found that obviously you can either use an environment variable per process or user or use db2set DB2CODEPAGE= for a complete DB2 instance. |
#6
| |||
| |||
|
|
Hi Joachim, I just want to clarify your understanding, because I think you have misunderstood the use or meaning of DB2CODEPAGE: DB2CODEPAGE is a client parameter. It is not instance related! So DB2CODEPAGE is user environment parameter. If your client user is the same as the instance user (in a 2-tier environment), then it seems like it is an instance parameter. But the data will be converted to the codepage which was defined in DB2CODEPAGE. This does not change the way how data is stored within the database. (e.g.: you can create another user on the same machine, initialize the db2 environment and set db2codepage to a different value - you will see that the output / conversion will be different) Hope this helps. |
#7
| |||
| |||
|
|
Hi Helmut, your comments indeed are very helpful and appreciated. I was completely on the wrong track and oversaw the obvious. So db2codepage really is an environment variable on the O/S level that each user can set individually, even on a per-application basis. It is not (necessarily?) some DB2-internal setting. Now that we are discussing it already, I'd like to ask that one last openquestion I still don't understand: what exactly is the difference between db2set DB2Codepage= and export DB2CODEPAGE= ? Does it make a difference who calls the db2set variant (Instance owner vs.. normal DB user)? Again, thanks for clarifying Joachim Am Mittwoch, 7. März 2012 22:10:23 UTC+1 schrieb Helmut Tessarek: Hi Joachim, I just want to clarify your understanding, because I think you have misunderstood the use or meaning of DB2CODEPAGE: DB2CODEPAGE is a client parameter. It is not instance related! So DB2CODEPAGE is user environment parameter. If your client user is the same as the instance user (in a 2-tier environment), then it seems like it is an instance parameter. But the data will be converted to the codepage which was defined in DB2CODEPAGE. This does not change the way how data is storedwithin the database. (e.g.: you can create another user on the same machine, initialize the db2 environment and set db2codepage to a different value - you will see that the output / conversion will be different) Hope this helps.- Hide quoted text - - Show quoted text - |
#8
| |||
| |||
|
|
there is no difference between the two. One reason for both possibilities: http://publib.boulder.ibm.com/infoce.../t0024163.html The IBM Data Server Driver for ODBC and CLI does not support the command line processor (CLP). This means that the usual mechanism to set DB2® registry variables, using the db2set CLP command, is not possible. Relevant DB2 registry variables will be supported with the IBM Data Server Driver for ODBC and CLI as environment variables instead. The DB2 registry variables that will be supported by the IBM Data Server Driver for ODBC and CLI as environment variables are: .... DB2CODEPAGE ... -- Frederik Engelen |
#9
| ||||
| ||||
|
|
so both have the same effect, but only the environment variable option is available when using the Driver packages. |
|
To me that means I prefer using the environment variable. And still this leaves me with some bitter taste: if I set the value using db2set, what is the scode of that setting? The db user? All connections that are established on this machine? |
|
I remember reading the text you cite several times but I must admit I never understood it and still don't. I never really understood the difference between db2 registry variables and environment variables. The fact that db2codepage is referred to as db2 registry variable to me somehow meant this is a db2 internal thing and therefor has to be maintained using db2set or the like. This put so much smoke around me that I even didn't dare trying the obvious ;-) |
|
So, even though my problem is solved, I still have some open questions... |
#10
| ||||||
| ||||||
|
|
To me that means I prefer using the environment variable. And still this leaves me with some bitter taste: if I set the value using db2set, what is the scode of that setting? The db user? All connections that are established on this machine? What do you mean by scode? I don't understand the question. |
|
But I think you are still confusing registry variables which apply to the instance and registry variables which apply to the client. |
|
You have to install a database client to connect to the server (these days you can also use the driver package which consists of basically a few files and does not come with a DB2 environment which is provided by the client). So, on the client you can set registry vaiables which apply to the client - not to the server. If you set the db2codepage registry variable or environment vaiable on the server, it would only affect the client environment on the server. |
|
You have to have an OS user to set up the database client (if you use a 2-tier environment, it will be most likely the same user as the instance user). If you set DB2CODEPAGE (either via db2set or export), you have to do this with an OS user. All connections done with this OS user will inherit this setting. A client connection with a different user and/or client will not be affected. |
|
As with a lot of things in DB2, they evolved during time. So the reason for environment and registry variables are as follows: In the beginning of time (DB2 time that is :-)), we had to reboot machines for environment variables to take effect. There was also the fact that you could (and still can) attach to an instance and administer the instance remotely. Most people ssh to the server and work with the instance directly though. Anyway, registry variables can be changed from a client when attached to the instance. Environment variables can not be. We created the registry variables to have environment variables which are under DB2 control and which can be changed via DB2 commands. |
|
So, even though my problem is solved, I still have some open questions... I tried to answer them. I hope my explanations were sufficient... |
![]() |
| Thread Tools | |
| Display Modes | |
| |