Martin Spd
Martin Spd

Reputation: 53

NetBeans: change Java project's charset causes problems

I like to ask if ever someone had same problem like me:

I started my project with encoding UTF-8 (was default project's encoding). But since I'm from central Europe I decided change encoding to Unicode, because I didn't want use english alphabet only in in JOptionPane.showMessageDialog() windows.
My application also connects to database and after changing charset to Unicode connection suddenly didn't work saying

com.mysql.jdbc.CommunicationsException:
Communications link failure due to underlying exception


Then I decided test it by changing charset back to UTF-8 and application was able connect again. I even compared my connection string characters positions if they are different in UTF-8 and Unicode, but they are same!

My question is: How can I use East European alphabet (different charset from default UTF-8) in my project, when I want avoid connection problems?

Upvotes: 0

Views: 414

Answers (1)

Martin Spd
Martin Spd

Reputation: 53

UTF-8 doesn't cover all symbols in Slovak alphabet, that's why I decided change charset to UTF-16. After compilation some of specific Slovak letters looks different in UTF-8 as I expected.
Thing I don't understand is, that if i change charset to UTF-16 something change my connection string (and it looks like jdbc:mysql://localhost/db_name?user=root&password=password), which contains symbols from ASCII code table only and my program can't connect...
With latin2 and Windows-1250 i have no problem connect and use Central-European characters. Is it some kind of bug that Unicode cause such problems in NetBeans 7.2?

Upvotes: 0

Related Questions