1

I am using Eclipse, with MY SQL Server 5.0. Using JFrame, I insert Tamil words into a textfield. However, the MY SQL console shows question marks instead of the Tamil words. I also see question marks in the textfield, but I am able to type there in Tamil using Alt+Shift key.

(Tamil being an indian language with special characters)

How can I properly switch to Unicode?

Clashsoft
  • 11,553
  • 5
  • 40
  • 79
aristocrat
  • 49
  • 5

2 Answers2

1
enter code here

try 
    {
        try
        {

         Class.forName ("com.mysql.jdbc.Driver"); 

        try

        {

      java.sql.Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydbase?useUnicode=true&characterEncoding=utf-8", "root", "ALPHAS");

      String sql = "insert into morph values(?,?,?)";

      String sql1 = "insert into  word values(?)";

      String sql2 = "insert into  stems values(?)";

    String sql3 = "insert into  suffixs values(?)";

             java.sql.PreparedStatement psmt = conn.prepareStatement(sql);

             java.sql.PreparedStatement psmt1 = conn.prepareStatement(sql1);

             java.sql.PreparedStatement psmt2 = conn.prepareStatement(sql2);

             java.sql.PreparedStatement psmt3 = conn.prepareStatement(sql3);

      String s= jTextField1.getText() ; 

      String sq = "select*from word";

      String sqlA = "select Word  from morph where Word ="+"'"+jTextField1.getText()+"'";

      try 

      {

      java.sql.Statement     stmtB = conn.createStatement();

      java.sql.ResultSet rsq = stmtB.executeQuery(sqlA);


      while(rsq.next())

       {

          String sA = jTextField3.getText() ; 

          String ds = "WordExists";

          if (s== sA)

                  {

              jTextField3.setText(rsq.getString("Word"));

              jTextField1.setText(rsq.getString("ds"));



                  }

          }
  } 

      catch (SQLException e ) 

  {
        e.printStackTrace();

  } 

      String sA = jTextField3.getText() ; 


char[] ch = s.toCharArray();

int y = s.length();

int k=1;

for (int m = y-1 ; m >=0; m--)

{
 String pl1 = new String(ch,0,m);

 if(pl1.length()>=2)

 {

  char[] dh = new char[y];

   int c=y-1;

   int g = y-1;



   for (int j=c; j>=0; j--) 

{

  if(m>=2)

    {

      dh[g] = ch[j];

          String pl = new String(ch,0,m);

          String mpm  = new String(dh,0,y);

        --m;

       // System.out.println(""+pl+"/"+mpm.trim()+"");

       // System.out.println(""+pl+"/"+mpm.trim()+"");


           g--;

           k++;

        if(k==y-1)


        {
             System.out.println(""+pl+"/"+mpm.trim()+"");

        psmt.setString(1,s);

        psmt.setString(2,pl);

        psmt.setString(3,mpm.trim()+"");  

       psmt1.setString(1,s);

        psmt2.setString(1,pl);

        psmt3.setString(1,mpm.trim()+"");  

        psmt.executeUpdate(); 
        psmt1.executeUpdate(); 
        psmt2.executeUpdate(); 
        psmt3.executeUpdate(); 

        }
                  }      
            }

             }
        }



        }

        catch(Exception E)
{
E.printStackTrace();
}    

    }
    catch(Exception E)
    {
        E.printStackTrace();
    }
    }
    catch(Exception E)
    {
         E.printStackTrace();
    }   
Yugesh
  • 4,030
  • 9
  • 57
  • 97
aristocrat
  • 49
  • 5
0

See UTF-8 all the way through

Question marks come from this:

  • The client has a valid character (good), and
  • The SET NAMES agrees with the encoding that the client has (good), but
  • The target column's CHARACTER SET does not include the intended character (bad).

The Tamil words are lost. You will need to fix the CHARACTER SET and re-INSERT the text.

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