Our company build process uses gradle and copies over the deliverables including sql file to a shared drive. Unix boxes can refer to these paths and then uses a shell script. The shell script invokes the db2 command line utility to run the sql files in the corresponding environment's database.
This works pretty well. However I have hit a wall where we are updating japanese characters in the sql file. When I download the file from the browser and inspect the file, I can see the characters properly. However, in the unix box, I can see that the content in the sql file looks pretty different. I used cat, more and vi to view the contents of the file. Value of the LANG environment variable is C. I see the environment variable set is TERM=XTERM. So I think xterm is the terminal evaluator.
LANG=C
When I run the command in the linux terminal window-
locale charmap
I see the encoding as ANSI_X3.4-1968. UTF-8 is one of the possiblities but that is not set in the box I think.
When I run the command in the linux terminal -
file -bi 1.sql
I see the charset encoding of the file as UTF-8.
When we run the shellscript which invokes the db2 command line utility, it inserts whatever I can see in the unix file and not the actual japanese characters.
I tries searching for options as to what could go wrong. Please find below my analysis -
When I run the sql from the Aqua Data Studio, data is inserted properly. So there is no issue with the actual database setup or the table configuration.
There are some other xml files in the shared path which have japanese characters. In unix box, I again see the distorted characters as I see in the sql file. When these xml files get copied to the reporting server, they work fine and the data is shown properly in the pdf.
So my line of thinking is that there can be some way I can specify in the db2 command line utility to use the correct character set and that should work fine. But I am unable to find anything useful on the internet.
Now there are chances that there is something small which I am not able to figure out. Hence I will request you to help me in this regard. This is not very critical as we can always leave the automated process of deployment and sql insertion , and instead go with the manual insertion by giving the scripts to the DBA. However this is highly discouraged.
Do let me know if you could help me with this regard. Just FYI, I unzipped the war produced after the gradle build (from the jenkins server). I can see the file properly in the notepad++. Do let me know if you need any other info.
If the Japanese characters do not render correctly in cat or more in your terminal window then it means that the LANG variable has the wrong setting. In your case LANG=C is not suitable for Unicode.
Some terminal emulators such as Putty, need to have the translation set to support UTF-8 and that may not be default - otherwise Unicode characters can render incorrectly on screen.
The correct LANG setting depends on your country, on which locales are installed in Linux, and also on the target database territory and codepage and Db2-server operating-system (i.e. Db2 for Z/OS , or i-series, or Linux/Unix/Windows). Sometimes you have to install additional locales if they were not installed by default, it depends on your Linux distro , platform, and version and installation policies.
The solution is normally to ensure you set the LANG variable correctly before you connect to any Db2 database. It's wise to assert such things in configuration checks that get automatically run by scripts. You get the correct value for LANG from the Db2 documentation, and that depends on your Db2-server operating system and version and your knowledge of the target database encoding and territory (or CCSID of the target database/tables/columns/tablespaces etc). For example, if your Db2-database lives on Linux/Unix/Windows, look at this page. Other pages exist for Db2 for Z/OS or i-series.
Once you change the LANG variable ( export LANG=...), again verify that more or cat renders the Japanese characters correctly. If you are already connected to the database, changing the LANG has no effect, so remember to disconnect first. Test the LANG values until the Japanese characters look correct, and only then try the Db2 connection and examine the new behavior.
Related
I'm working with a scriptable CAD/CAM system that runs on Windows 10 whose built-in code pane is not very useful. The user-defined scripting code for this CAD/CAM system is not saved in text files, but rather, in a field in an SQL Server. I'm thinking there might be some way of setting up Visual Studio/VSCode (or maybe Notepad++) to work with the code in the database the same way it would do if were in a text file. I could probably set up some sort of .Net FileSystemWatcher utility that keeps a bunch of code files it sees in a directory synched with code in the SQL Server data field. But I have deadlines, and I'm supposed to be scripting this CAD/CAM system--not building tools to script the CAD/CAM system. Any ideas for a "quick fix"?
There is an application on remote machine with Linux OS(Fedora), writing to the log file when certain events occur. Some time ago I changed format of the message being written to the log file. But recently it turned out that for some reason in some seldom cases log files with old format messages appear there. I know for sure that none part of my code can write such strings. Also there is no instance of the old application running. Does anyone have some ideas why it can happen? It's not possible to check which process writes those files because anything like auditctl is not installed there, and neither package manager or yum to get it or install. Application is written in C language.
you can use fuser command to find out all the processes that are using that file
`fuser file.log`
My test program works fine. I can create a client and a server and run them against each other. I can set my KRB5_CONFIG environment variable and use a local configuration for testing.
For some reason when I place the code in our production software it fails. Even if I strip our main() function to just calling gss_import_name() with a hard coded name I end up with the message "Cannot open configuration file".
If I run truss then I see a lot of Oracle going on. It tries to open lots of different Oracle trace files. It also tries to open
/krb5/krb.conf
instead of the file I specify.
It's as if Oracle is giving us the wrong gss, or maybe some other option in our huge and complex build system. I note -L/usr/lib/sparcv9 though this is after my -lgss now if that matters (too long since I worked in C on a regular basis!). The libgss.so.1 in that directory is larger than the one in /usr/lib - though putting that option into my test program's link command does not break it.
Any help?
Thanks
- Richard
This fixed what appeared to be a similar problem for us:
export KRB5_CONFIG=/etc/krb5.conf
It does appear likely that Oracle sets this env var incorrectly if it's not already set.
$ grep -r KRB5_CONFIG $ORACLE_HOME
Binary file /usr/lib/oracle/11.1.0.1/client64/lib/libclntsh.so matches
Binary file /usr/lib/oracle/11.1.0.1/client64/lib/libclntsh.so.11.1 matches
$ grep -r '/krb5/krb.conf' $ORACLE_HOME
Binary file /usr/lib/oracle/11.1.0.1/client64/lib/libclntsh.so matches
Binary file /usr/lib/oracle/11.1.0.1/client64/lib/libclntsh.so.11.1 matches
I found that the Oracle libraries contained an implementation of GSS. To make my code work I ensured I linked "-lgss" before linking any of the Oracle libraries.
I've not tested to see if this upsets Oracle in single sign-on, because we use Oracle with user name and password. That works fine.
I ran in to the very same issue with Oracle 11.2.0.4.0 on HP-UX 11.31 and wasted almost an entire day for that. Indeed, the crappy Oracle lib peforms a putenv with /opt/krb5/krb.conf and the tip from Richard Corfield makes the app even crash. The only workaround is to create a symbolic link. I have created a service request with Oracle for that issue.
Update (2014-06-02): I have received an update from Oracle. They confirmed the bug. It seems like there is a private GSS-API which is redefining symbols.
Bug 10184681 - ORACLE NEEDS TO USE VERSIONED SYMBOLS TO AVOID EXTERNAL SYMBOL CONFLICTS
This issue has been open since 2010-10. Terrible.
I have a database file with .DB file extension. I have been googling and it looks like SQLite. I tried to connect to it using SQLite and SQLite3 drivers and I am getting an error "File is encrypted or not a database".
So I dont know if file is encrypted or it is not an SQLite database. Are there any other options what should the .DB extension should be? How do I find out that file is encrypted?
I tried to open it in the text editor and it is mostly a mess of charaters and some times there are words visible. I have uploaded the file here: http://cl.ly/3k0E01373r3v182a3p1o for the closer look.
Thank you for your hints and ideas what to do and how to work with this file.
Marco Pontello's TrID is a great way to determine the type of any file.
TrID is simple to use. Just run TrID and point it to the file to be analyzed. The file will be read and compared with the definitions in the database. Results are presented in order of highest probability.
Just download the executable and the latest definitions file into the same directory and then run TrID:
trid.exe "path/to/file.xyz"
It will output a list of possible file types for the file with a confidence rating. Here's a screenshot of using TrID to analyze a SQLite database file:
There's also a GUI version called TrIDNet:
If you're on a Unix-like platform (Mac OS X, Linux, etc), you could try running file myfile.db to see if that can figure out what type of file it is. The file utility will inspect the beginning of the file, looking for any clues like magic numbers, headers, and so on to determine the type of the file.
Look at the first 30 bytes of the file (open it in Notepad, Notepad++ or another simple text viewer). There's usually some kind of tag or extension name in there.
Both SQLite 2 and SQLite 3 have a very clear message: SQLite format 3 for SQLite 3 (obviously) and This file contains an SQLite 2.1 database for SQLite 2.
Note that encrypted SQLite databases don't have a header like that since the entire file is encrypted. See siyw's comment below.
On a Unix-like system (or Cygwin under Windows), the strings utility will search a file for strings, and print them to stdout. Might help you narrow the field.
There are a lot of programs besides database programs that use a "db" extension, including
ArcView Object Database File (ESRI)
MultiEdit
Netscape
Palm
and so on. Google "file extensions" for some sites that catalog file extensions and the programs that use them.
There's no conclusive way to know, because SQLite encrypts the entire database file, including the header.
Further, there's not a lot of difference to you, except for possible error text to a user if you're prompting them for a password.
There is a strange issue about sybase interfaces file. We have an application which is run on solaris sparc OS and this application uses open client (sybase OCS-12_5) for database operations. When we upgrade our database server to sybase 15.03, our application didn't work. then I start the research for figure out why it does not work. End of the my research, i found the the reason is sybase15.03's interfaces file. Somehow,15.03's interfaces file is damaged i think. But sybase 12.5 interfaces file and sybase 15.03 interfaces file is same.I checked interfaces file for unknown character or carrige return character but there is no any strange character in it. When I copied sybase12.5's interfaces file to sybase15 directory, application runs correctly. Is there anyone to explain this?
PS: Sybase libraries looks for $SYBASE env. variable and reads the $SYBASE/interfaces file for gather server information like server host and port
Thanks and regards.
Sounds like a minor error in the 15.0.3 interfaces file format.
Suggested approach to diagnosing:
(Unix) diff the working and non-working interfaces files - if the servers they describe is the same the difference should be apparent pretty quickly.
Check the format against the rules in Sybase documentation.
If the problem is still not manifest, then 'divide an conquer' might be the next step - try a smaller subset of the problem interfaces file.
Failing that, you could post equivalent entries from the two files here and see if the community can spot the problem.
Check for the space in between lines and make sure there is a extra empty line at the end of the interface file.
Another thing to make sure is the network setting you have choose. It should be the same. It would be most probably TCP. Some versions in 12.5 used to put other entries.
Another method to correct this is to use a DSCP method. This ensures that the interface file is correct.