0

I cannot retrieve my unicode data from my mysql database. Help me. I have briefed down about how I created my unicode database table and how I tried to retrieve the unicode data.

This is how stored my Unicode (tamil) data into my mysql in xampp server Windows 8:

  • I created a database using create database library
  • Inside that database, I created a table using

    create table book 
    (
        id integer primary key auto_increment,
        name text default '',
        auth text default ''
    ) engine=InnoDB default charset=utf8 collate=utf8_unicode_ci;
    
  • I had a .csv file encoded in utf-8. The following image shows its content.

    csv file content - image

  • I have input my .csv into the table using the following query

    load data local infile 'C:\\Users\\Ramvignesh\\Desktop\\lib1.csv' into table library.book fields terminated by ',' enclosed by '"' lines terminated by '\r\n' (id,name,auth);
    
  • The following image shows how the data had been stored in my db table.

    db table - image

This is how I tried retrieving my Unicode (tamil) data:

  • I created a jsp code which is as follows.

    <%@ page import="java.sql.*"%>
    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
    <!DOCTYPE html>
    <html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    </head>
    <body>
      <%
                PreparedStatement st=null;
                ResultSet rs=null;
                Class.forName("com.mysql.jdbc.Driver"); 
                Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/library","root","");
      %>
                <table> 
                <thead>
                    <tr>
                        <th>id</th>
                        <th>name</th>
                        <th>author</th>
                    </tr>
                </thead>
                <tbody>
      <%
                st= con.prepareStatement("select * from book");
                rs=st.executeQuery();
                while(rs.next()){
    
      %>
                <tr>
                    <td><% out.println(rs.getString(1));%></td>
                    <td><% out.println(rs.getString(2));%></td>
                    <td><% out.println(rs.getString(3));%></td>
                </tr>
      <%    
               }
      %>
            </tbody>
            </table>
    </body>
    </html>
    
  • The following image shows the output for my code.

    jsp page - image

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ramvignesh
  • 210
  • 6
  • 16

1 Answers1

1

Please provide machine-readable versions of those images.

Please do SELECT col, HEX(col) FROM tbl WHERE ...; for some mangled text so we can figure out whether the data was even stored correctly.

Meanwhile, I will guess that you have Mojibake. See duplicate for discussion and solution, including how to recover the data via a pair of ALTER TABLEs.

Community
  • 1
  • 1
Rick James
  • 135,179
  • 13
  • 127
  • 222