java - How to query a UTF-8 database using JDBC -


my db2 database using utf-8 encoding. source table has 1 colum utf-8 text these lines below

greek: Μπορώ να φάω σπασμένα γυαλιά χωρίς να πάθω τίποτα
czech: mohu jíst sklo, neublíží mi
serbian: Ја могу да једем стакло

java code doing (.. snipped out irrelevant parts.. )

resultset rs = stmt.executequery("select sample_text unicode_test"); file file = new file("unicode.txt"); bufferedwriter outfile = new bufferedwriter(new outputstreamwriter(new fileoutputstream(file),"utf8")); while (rs.next()) {     outfile.write(rs.getstring("sample_text"));     outfile.write( "\n" ); } 

the result in file don't in source table @ all. instead

greek: ΜποÏÏŽ να φάω σπασμένα γυαλιά χωÏίς να πάθω τίποτα
czech : mohu jíst sklo, neublíží mi
serbian: Ја могу да једем Ñтакло

did miss?

your java code ok. sure file content wrong? see can appear wrong if have terminal wrong, example. can see ok other text files in computer encoded utf-8? (if unsure, read in hexa, dump od, etc). if sure not problem, i'd point charset encoding setting in jdbc connection (no experience db2).


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -