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.
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.
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.