JDBC mysql with latin1 charset - mysql

I've a simple java script that use jdbc to get data from mysql table (CHARSET=latin1). I've chinese words in a field and it looks correct when I do a select from mysql prompt but when I run it from the java it display incorrect characters.
The jdbc url I've this and seems not help.
jdbc:mysql://dev-mt01:3306/mundotrack?characterEncoding=Cp1252&useUnicode=yes
I also added this in the url characterSetResults=Cp1252 and seems still doesn't help.
I got the Cp1252 from this page.
http://dev.mysql.com/doc/connector-j/en/connector-j-reference-charsets.html
Any idea? Thanks.

Related

UTF-8 encoded MS Access table

I have a MS Access table which is encoded in UTF-8 charset and the characters appear like this:
Participació en comissió
If I UTF-8 decode this text I get the correct text:
Participació en comissió
How can I utf-8 decode several Access table columns? I would like to end up with the same MS Access database but with the columns converted (utf-8 decoded). I cannot figure out an easy way to do this conversion.
Thanks in advance.
--
More clarifications:
So how did you decode the text that you have in the question?
I simply put the sentence in an online utf-8 decoder but it crashes when there is a lot of text. FYI, the Access table comes from a MS SQL Server database with Modern_Spanish_CI_AS collation and varchar (MAX) data type field. Maybe is there a way to perform the conversion while exporting the table from the MS SQL Server?
While searching for a solution I found this post that has a function to decode utf-8 fields right from the MS SQL Server. I tested it and it works perfectly, althought it is quite slow. Hope this helps someone else with the same problem.
New query editor and copy&paste the function provided in this link:
Convert text value in SQL Server from UTF8 to ISO 8859-1

JdbcTemplate do not mapping result to map : related with windows ascii

I got a dump file from MSSQL. It is encoded with euckr and has some windows ascii character like ^F, ^D, M.
What I am trying to do is ...
LOAD DATA LOCAL INFILE '{My CSV FILE}' INTO TABLE '{TARGET TABLE}' CHARACTER SET euckr FIELDS TERMINATED BY '|:' - push csv to MYSQL
read the data from MYSQL with jdbcTemplate on java source code
After LOAD ..., I can see the data in workbench and it looks normal.(It does not display any special characters I mentioned above.)
However, when execute jdbcTemplate.queryForMap, it could not push the result to Map and I assume MS ascii is the reason.
Error message is (I typed this since windows console does not able to copy)
org.springframwwork.dao.TransientDataAccessResourceException:
PreparedStatedmentCallback; SQL [SELECT * FROM TARGET_TABLE];
Value '^A4 data1 1999-00-00^Fabc^D0000^A0^#...'
How can I eliminate this special characters?
Do I request new MSSQL dump file without those? (I do not know is it possible to eliminate in MSSQL. I have no experience with MSSQL)
Is there anyway to do some works before jdbctemplate mapping result?
Thanks.
FYI,
Mysql encoding is UTF8, and version is 5.6.35
I am not sure, but in my experiment ,,,
LOAD DATA LOCAL INFILE in Windows makes some weird characters like that.
Execute same query in OSX or Linux(In my case, CentOS mysql client) looks fine.(Do not insert characters like ^M)

phpMyAdmin won't display or insert Unicode characters properly into database

I'm using phpMyAdmin version 4.4.4 with MySQL 5.6 (charset is set to UTF-8 Unicode). The table in question has the collation set to utf8-general-ci and all fields are also set to utf8-general-ci collation as well. My php.ini file has default_charset = "UTF-8".
Despite all the UTF-8 settings for all three applications, unicode characters appear garbled when viewing a table within phpMyAdmin. So, instead of seeing ...
Søren
... in phpMyAdmin I see ...
Søren
Even though it displays garbled in phpMyAdmin, it displays correctly on the website. The only problem is with phpMyAdmin.
If I attempt to Insert a new record using phpMyAdmin and enter Søren in a text field, it displays like this within phpMyAdmin...
Søren
Which looks correct there, but, on the web page, it displays like this...
S�ren
The ø character is replaced with a question mark inside a black diamond instead of displaying the proper unicode character on the website.
What the heck is going on? How do I make phpMyAdmin display and insert the unicode characters properly into the table without mangling them? Thanks!
My php.ini file has default_charset = "UTF-8".
That only affects the charset used for some PHP built-in functions like htmlentities.
MySQL uses its own charset to decode stuff you send it. This can be set using $mysqli->set_charset('utf8') for mysqli, or mysql_set_charset('utf8') for the deprecated mysql module, or using charset=utf8 in the connection string in PDO.

MySql to SPSS via ODBC- cannot retrieve strings

I am using MySQL 5.6, SPSS 22 and ODBC GUI with Actual ODBC Pack (for Mac OS X) 3.2.1 on Mavericks OS.
I am able to connect to the database, select the table and even the fields . The table has about 20 string variables and 10 numeric. All looks normal as I go through each step.
When I retrieve the data into SPSS, all the numeric variables import fine. The strings are a garbled mess. (See attachment). However, you can see on the variable view, all the string variables names are fine.
I rebooted and restarted both Mysql and SPSS and got the same results.
Any suggestions?
I can't make out what the strings look like from the picture, but your description sounds like there is an encoding problem. Try changing the Unicode and locale settings (Edit > Options > Language) in Statistics or find out what the encoding is in the database and try to match that.
It is an encoding issue. In SPSS, without a data set loaded, go to Edit > Options > Language and change the character encoding for data setting to Locale's writing system. Then run your database query again.

Why does PhpMyAdmin seem to break my Character Encoding?

I wrote a short script which simply inserts Unicode characters into a MySQL database. It looks like this:
mysql_connect('localhost', 'root', '*') or die(mysql_error());
mysql_select_db('test') or die(mysql_error());
mysql_query("INSERT INTO thetable (thefield) VALUES ('äöüß')") or die(mysql_error());
I generated the script using Notepad++ and it's UTF-8 encoded without BOM.
The database and the table have a utf8_general_ci collation. When I look at the data using PhpMyAdmin then the charset seems to be broken. The characters are not displayed correctly:
äöüß
When I receive the data back in my script then the charset seems to be okay. I dumped it with the right header (header('Content-Type: text/html; charset=utf-8')) and everything looks right.
When I insert data into the table using PhpMyAdmin again, then it is displayed correctly inside PhpMyAdmin, but as soon as I dump it from my Demo script, then the charset is broken again.
I have no idea what the reason could be. The database's charset, the HTTP header and the encoding of the script are consistent and I don't doubt that PhpMyAdmin is working correctly. So where else could I look for the problem?
Your getting 2 characters for every one in the original, so its reading it as standard ASCII instead of unicode. you probably need to specify the character set the MySQL Connection is using when you connect.
I'm on my cell, but if u post your DB connect code I can show you how when I get to a computer
Edit - see PHP PDO: charset, set names?