Hi...
I am working on project related to localization.I want to add marathi text to mysql table.But when i add it through jsp page it shows garbage values.Can u suggest any solution to this problem.
Thank you.
Printable View
Hi...
I am working on project related to localization.I want to add marathi text to mysql table.But when i add it through jsp page it shows garbage values.Can u suggest any solution to this problem.
Thank you.
Hello vaishali.
Welcome to the Java Programming Forums.
Can you please post the code that you have written.
It will be near impossible to diagnose your problem without it..
Thanks.
Hi...
Thanks for reply.Actually i am using java,mysql database with netbeans 6.1.Whenever i try to add through command editor it will add values correctly.But whenever i add it through program it will shows '??' marks instead of values.
Below i am pasting the code which i had used.
Java code to insert values.I have used jsp page for that.
Code :<%@page contentType="text/html" pageEncoding="UTF-8"%> <%@ page language="java" import="java.sql.*,java.util.Enumeration" import="java.sql.Connection" %> <html> <head> <title>Test</title> </head> <body> <% String url="jdbc:mysql://localhost:3306/MyNewDatabase"; Connection con = null; Statement stmt; ResultSet rs = null; String query,query1; PreparedStatement stmt1; try{ try{ Class.forName("com.mysql.jdbc.Driver"); } catch(Exception e) { out.println("driver_not_found"+e.getMessage()); } con = DriverManager.getConnection (url,"root","mysql123"); int id1=1115; String word1="आई"; String pos1="noun"; stmt1=con.prepareStatement("insert into htb_all_words1 values('"+id1 +"','"+word1+"','"+pos1+"')"); stmt1.executeUpdate(); stmt = con.createStatement(); query = "select * from htb_all_words1 "; ResultSet result = stmt.executeQuery(query); while(result.next()) { String id= result.getString(1); String word2=result.getString(2); String pos2=result.getString(3); %> <br><% out.println(id);%> <% out.println(word2);%> <% out.println(pos2);%> <% } } catch(Exception e) { out.println("SQLException_caught:_" + e.getMessage()); } finally { try { if (con != null) con.close(); } catch (SQLException e) {} } %> <br> Second JSP page................... </body> </html>
THIS IS THE OUTPUT I AM GETTING
Code :!-- Document : keyboard Created on : Sep 16, 2008, 10:24:59 PM Author : staff --> 1 धन verb 2 पुण verb 3 पुण verb 10 पुण verb 11 ?? noun 99 शोध noun 100 पुण verb 111 905 noun 112 u0905 noun 113 905 noun 114 905 noun 115 u0905 noun 116 \u0905 noun 1000 ?? verb 1001 पुण noun 1002 †œ noun 1003 †œ noun 1004 धन verb 1111 ?? noun 1113 ?? noun 1114 आई noun [COLOR=red]1115 ?? noun [/COLOR] Second JSP page...................
This sounds like a classical UTF-8 madness issue, you need to make sure your database accepts UTF-8 as well, have you had a look in it to see what the data is actually like?
After that you need to make sure the JSP page is actually set to use the correct character set so that the website is sent to the browser as UTF-8. You could have a look at content type for this.
Last thing to do might be to check your servlet container and make sure it is set up to deliver and handle UTF-8.
// Json