2011-09-07 52 views
-2
here are the settings 

this time using odbc connection 

![showing u the settings][1] 


[1]: http://i.stack.imgur.com/4f2bD.jpg 

and 

![ i have mentioned utf8 here][1] 


[1]: http://i.stack.imgur.com/C9fo5.jpg 

here is my code 


<%-- 
Document : index.jsp 
Created on : 30 Aug, 2011, 10:57:05 AM 
Author  : Sahil 
--%> 
<%@page contentType="text/html" pageEncoding="UTF-8" import = "java.sql.*;"%> 
<%@page import = "java.util.*"%> 
<%@ page import = "java.io.*"%> 
<%@page import= "java.lang.RuntimePermission" %> 
<!DOCTYPE html> 
<html> 
<head> 
<title>Punjabi-Hindi Dictionary | Output</title> 
<link href="style.css" rel="stylesheet" type="text/css" media="screen" /> 
</head> 
<body> 
    <form accept-charset="UTF-8"> 
    <% 

    try 
     { 
     if (request.getCharacterEncoding() == null) 
      request.setCharacterEncoding("UTF-8"); 
     Connection cn; 

     Statement st; 
     ResultSet rs; 
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
     cn=DriverManager.getConnection("jdbc:odbc:myodbc","root",""); 
     st=cn.createStatement(); 
     rs=st.executeQuery("select * from stu_info"); 
     while(rs.next()){ 
     String Name= rs.getString("Name"); 

    %> 
    <%=Name%> 
    <br> 
     <% 
         } 
    rs.close(); 
    st.close(); 
    cn.close(); 
    } 
    catch(Exception ex) 
    { 
     out.println(ex.getMessage()); 
    } 
     %> 

    </form>  
    </body> 
    </html> 

    this time it gives me diffrent output 

    साहिल 
    साहिलसाहिल 
+0

我不知道爲什麼我不能看到圖像 –

+0

我已經使用列數據類型varchar(50)和排序規則是utf8_general_ci –

+0

可能的重複[Getting ??????而不是使用JSP的MySQL數據庫的印地文文本](http://stackoverflow.com/questions/7318757/getting-instead-of-hindi-text-from-mysql-database-using-jsp) – BalusC

回答

-1

顯然你的輸出是一個單頁編碼(如ISO-8859-1),而不是UTF-8,這可能有幾個原因:

  • 你檢查過的數據是否正確存儲在你的數據庫中?如果不是,則應檢查用於存儲數據的表是否爲UTF-8
  • 數據庫連接是否正確設置爲使用UTF-8?我不知道這是ODBC完成,但爲MySQL-JDBC驅動程序可能需要附加給你的配置URL:

    的characterEncoding = UTF-8

+0

是的,我檢查了我的數據被正確存儲。 –

+0

你可以在評論中提示我。 –

+0

我已經做到了這一點...但再次不工作 –