aspose file tools*
The moose likes JDBC and the fly likes How to distinguish the character encoding the MySql is using and the System is using? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to distinguish the character encoding the MySql is using and the System is using?" Watch "How to distinguish the character encoding the MySql is using and the System is using?" New topic
Author

How to distinguish the character encoding the MySql is using and the System is using?

ken jun
Ranch Hand

Joined: Apr 23, 2010
Posts: 46
If I want to write a java to connect to the MySql ,needing to insert some data to it and then I need to convert the system's character into the database's character,but I don't know which character encoding the database is using. So how can I get the character encoding the system is using as well as the MySql.

Thanks
jun
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40027
    
  28
System#getProperty(String). If you can't get anything useful with "encoding" try System.getProperties and iterate through the Enumeration it returns.
You should be able to select the database's properties in MySQL but I can't remember how.
ken jun
Ranch Hand

Joined: Apr 23, 2010
Posts: 46
Campbell Ritchie wrote:System#getProperty(String). If you can't get anything useful with "encoding" try System.getProperties and iterate through the Enumeration it returns.
You should be able to select the database's properties in MySQL but I can't remember how.


Thank you Campbell

I know I can select the character encoding of the database but if I want to distribute a program for others to run, I have no idea what the user's properties. So could you tell me some method to solve the problem that how to know the character encoding which the database is using...
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40027
    
  28
Don't know myself, sorry.
ken jun
Ranch Hand

Joined: Apr 23, 2010
Posts: 46
Campbell Ritchie wrote:Don't know myself, sorry.

haha no problem anyway thanks a lot
Madhan Sundararajan Devaki
Ranch Hand

Joined: Mar 18, 2011
Posts: 312

I believe, using JDBC compliant DML statements, will allow your Java program to be easily run against standard RDBMSs such as MYSQL. In other words, you need not worry, if you use JDBC compliant DML statements in your Java programs.


S.D. MADHAN
Not many get the right opportunity !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to distinguish the character encoding the MySql is using and the System is using?