Unicode support Java
Few days back, I was working on one project, Project was in MySql, Java. I had to do Java, MySql Connectivity. My database was in Gujarati. (Unicode, UTF-8)
To do MySql database connection using Java is very easy.
string url = "jdbc:mysql://ServerIPAddress:3306/DatabaseName
Where,
1. jdbc : Driver specification
2. mysql : Defining MySql database is used.
3. ServerIPAddress : This is the IP Address of the database server
4. 3306 : Port
5. DatabaseName: Name of Database
So I thought this is perfect for connectivity..
Oops... but garbage value displayed when I fetched data. So what to do?
I had spent 1 week to find out what is the problem? Where is the problem?
Finally, I found the solution, Need to pass parameter for Unicode support.
Then, I used below string as connection:
string url = "jdbc:mysql://ServerIPAddress:3306/DatabaseName?useUnicode=true&characterEncoding=UTF8";
and its done.
useUnicode=true&characterEncoding=UTF8 : Property needs to be set for
using Unicode database.
To do MySql database connection using Java is very easy.
string url = "jdbc:mysql://ServerIPAddress:3306/DatabaseName
Where,
1. jdbc : Driver specification
2. mysql : Defining MySql database is used.
3. ServerIPAddress : This is the IP Address of the database server
4. 3306 : Port
5. DatabaseName: Name of Database
So I thought this is perfect for connectivity..
Oops... but garbage value displayed when I fetched data. So what to do?
I had spent 1 week to find out what is the problem? Where is the problem?
Finally, I found the solution, Need to pass parameter for Unicode support.
Then, I used below string as connection:
string url = "jdbc:mysql://ServerIPAddress:3306/DatabaseName?useUnicode=true&characterEncoding=UTF8";
and its done.
useUnicode=true&characterEncoding=UTF8 : Property needs to be set for
using Unicode database.
Comments
You can use code formatting for putting code like code tag..