Query isn't executing even after connecting with database

I have made a frame and connecting to database, its connecting but query isn't executing. What is going wrong.

 Connection myCon = null;
    Statement mystmt =null;
    ResultSet myRs = null;
        String grammar = gname.getText();

   myCon = DriverManager.getConnection("jdbc:mysql://localhost:3306/grammar","root","");
   JOptionPane.showMessageDialog(rootPane, "Connected to database");
   mystmt = myCon.createStatement();
   String query ="select starting_symbol,nonterminals,terminals from input_values INNER JOIN starting_symbol where input_values.grammar = starting_symbol.grammar='"+grammar+"'";
   myRs= mystmt.executeQuery(query);

       String s = myRs.getString("start_symbol");
       String nonT = myRs.getString("non_terminals");
       String t = myRs.getString("terminals");

       JOptionPane.showMessageDialog(rootPane, s);

    }catch(HeadlessException | SQLException e){
        JOptionPane.showMessageDialog(rootPane, "NO Result");

this is code.

these are outputs:

enter image description here

enter image description here