将查询参数从php传递到java jar文件

I have a login page written in php and I want to pass the query to a jar file ,the java jar file should check the query sent by php for some keywords ,can someone help me please! thanks.

this is a part of my php code

<?php
 $username=$_POST['username'];
 $password=$_POST['password'];

 if($username&&$password)
  {
   $connect=mysql_connect("localhost","root","123") or die("Couldnt connect to Database");
   mysql_select_db("test") or die("Couldnt find Database");
   $query = mysql_query("SELECT * FROM users WHERE username='$username'");
    exec("java -jar QuerySignature.jar $query");

    $numrows = mysql_num_rows($query);

    if($numrows!==0)
     {
        while($row = mysql_fetch_assoc($query))
     {
      $dbusername = $row['username'];
      $dbpassword=$row['password'];
       }
      if($username==$dbusername&&$password==$dbpassword )
          {
        echo "You are logged in!";

I excuted the jar file and sent the $query as an argument I want the java program to read the query it self NOT the return value

 exec("java -jar QuerySignature.jar $query");

Am I doing right here?

and this is my java program QuerySignature.java

       public static void main (String a[])
      { QuerySignature q1= new QuerySignature();
      String s = "select * from employee where id=20 and name='Angel' or age=20";
       String QueryKey = q1.Msg_Init(s);
      try {
      q1.Msg_Md5(QueryKey);
      } catch (Exception e) {}

I want to know, how to execute the passed argument from php instead of this line in my java program:

"select * from employee where id=20 and name='Angel' or age=20";

Sorry ,I know I am being annoying here ..but help me out and thank u.