title: How to pass array of sql query to function
body: <p>What's wrong in code.
  Please help me on this.
  How do I pass array of query to function exeSearchQuery();</p>
  
  <pre><code>  public class  MyDBConnect
      {
      Connection dbCon = null;
          public String DB_USERNAME = "root";
          public String DB_PASSWORD = "root";
          private String DB_DRIVER_CLASS = "com.mysql.jdbc.Driver";
          private String DB_URL = "jdbc:mysql://localhost/yatin";
      public  boolean connectToDb( ) throws Exception{
          try{
      Class.forName (DB_DRIVER_CLASS);
              dbCon = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD);
              //dbCon = DriverManager.getConnection(tns, DB_USERNAME, DB_PASSWORD);
              return true;
          }catch(Exception e){
              System.out.println("Error in DBConnect "+e);
              return false;
          }
      }
  
      public ArrayList exeSearchQuery(String sql[]) throws Exception{
  
          Statement stmt = null;
          ResultSet rs = null;
          ArrayList  data = null;
          int recordSize=0;
              try{
  
                  connectToDb( );
                  stmt = dbCon.createStatement( );
                  rs = stmt.executeQuery(sql);
                  ResultSetMetaData rsmd = rs.getMetaData();
                  int numOfCols = rsmd.getColumnCount();
  
                  data = new ArrayList( );
                  String q="";
                  for(int k=0;k&lt;2;k++)
                  {
                      boolean chkQuery=true;
                      q=sql[k];
                      while(rs.next()){
                      chkQuery=true;
                      recordSize=recordSize+1;
                      String row[] = new String[numOfCols];
                      for(int col=1;col&lt;=numOfCols ;col++)
                      {
                          row[col-1] = rs.getString(col);
                      }
                      data.add(row);
                      }
                      System.out.println("data="+data);
  
                      if(chkQuery=true)
                          {
                          break;
                          }
                          else
                          {
                              q=sql[1];
                              while(rs.next())
                              {
                                  chkQuery=true;
                                  recordSize=recordSize+1;
                                  String row[] = new String[numOfCols];
                                  for(int col=1;col&lt;=numOfCols ;col++)
                                  {
                                      row[col-1] = rs.getString(col);
                                  }
                                  data.add(row);
                                  System.out.println("data="+data);
                              }
                          }
                          if(chkQuery=true)
                          {
                          break;
                          }
                      }
  
              }catch(Exception e){
                  System.out.println("Error in DBConnect "+e);
              }finally{
                  if(rs !=null) rs.close();
                  if(stmt !=null)stmt.close();
                  if(dbCon !=null) dbCon.close();
              }
          return data;
          //return recordSize;
      }
  
          public static void main(String a[]) throws Exception{
              MyDBConnect db = new MyDBConnect( );
              //db.connectToDb();
                              System.out.println("Connected");
              String query[] ={"select a.ID,a.VDT,a.AID,a.NAME,a.ADD,a.CONTACT,a.PTM,a.DEPT_TEXT,a.FLOOR,b.LINK from tm_co123 a LEFT JOIN tm_co456 b ON a.ID=b.PID where a.NAME like 'anil' ORDER BY ID","select a.ID,a.VDT,a.AID,a.NAME,a.ADD,a.CONTACT,a.PTM,a.DEPT_TEXT,b.LINK from tm_co123 a LEFT JOIN tm_co456 b ON a.ID=b.PID where a.ADD like 'anil' ORDER BY ID"};       
              db.exeSearchQuery(query[]);
          }
      }
  </code></pre>
  
  <p>If I run above code I am getting Error as </p>
  
  <pre><code>MyDBConnect.java:473: '.class' expected
                  db.exeSearchQuery(query[]);
                                           ^
  1 error
  </code></pre>
  
  <p>If I replaces query[] with query then it givs me Error as</p>
  
  <pre><code>MyDBConnect.java:406: executeQuery(java.lang.String) in java.sql.Statement canno
  t be applied to (java.lang.String[])
                          rs = stmt.executeQuery(sql);
                                   ^
  Note: MyDBConnect.java uses unchecked or unsafe operations.
  Note: Recompile with -Xlint:unchecked for details.
  1 error
  </code></pre>