title: retrieve hindi character from database
body: <p>I have written a program which makes a search for the given hindi word in the mysql database and retrieves its corresponding name in english which is stored in the database.It works fine when i give the hindi word directly in the select statement but i would like to give it using a variable so it could be more general but i am not getting the result for the same..Could anyone help me with a solution to it..Thanks in adavance</p>
  
  <p>This is the code which i have written</p>
  
  <pre><code>import java.sql.DriverManager;
  import java.sql.Connection;
  import java.sql.SQLException;
  import com.microsoft.sqlserver.jdbc.*;
  import java.sql.*;
  
  public class Example {
  
  public static void main(String[] argv) {
  
  
      try {
  
          Class.forName("com.mysql.jdbc.Driver");
  
          } 
      catch (ClassNotFoundException e) 
          {
  
          System.out.println("Where is your MySQL JDBC Driver?");
          e.printStackTrace();
          return;
  
          }
  
  
      Connection connection = null;
  
                           SQLServerDataSource dataSource = new SQLServerDataSource();
                                   dataSource.setServerName("COMP-PC");
                                  dataSource.setPortNumber(1433);
                                dataSource.setDatabaseName("concept");
                                dataSource.setUser("root");
                              dataSource.setPassword("abc");
  
          try
           {
          connection = dataSource.getConnection();
          connection.setAutoCommit(false);
          System.out.println("Connected to server !!!");
           Statement select = connection.createStatement();
           String var="N'हल्दी'";
  
       ResultSet result = select.executeQuery
  
  
  
                 ("SELECT Name, Id FROM MConcept where CName=N'हल्दी'");  
       **// When given like the above statement it works fine 
  
  
  
                   ("SELECT Name, Id FROM MConcept where CName='"+var+" ' "); 
      **//This does not give result 
  
  
        System.out.println("Got results:");
        while(result.next()) { // process results one row at a time
  
        String Name = result.getString(1);
        int ID = result.getInt(2);
  
         System.out.println("name = " + Name);
         System.out.println("id = " + ID);
         }
        select.close();
       connection.close();
        }
  
  
  
  
    catch (SQLException e)
    {
     System.out.println("Connection Failed! Check output console");
     e.printStackTrace();
     return;
     }
  
      if (connection != null)
       {
      System.out.println("Successfully connected!");
  
       } 
     else 
      {
  System.out.println("Failed to make connection!");
      }
  
  
     }
   }
  </code></pre>