private static List<List<?>> executeH2Query(String sql,Object[] args) throws SQLException {
  List<List<?>> res=new ArrayList<>();
  ResultSet rs=null;
  try (PreparedStatement st=conn.prepareStatement(sql)){
    for (int idx=0; idx < args.length; idx++)     st.setObject(idx + 1,args[idx]);
    rs=st.executeQuery();
    ResultSetMetaData meta=rs.getMetaData();
    int colCnt=meta.getColumnCount();
    while (rs.next()) {
      List<Object> row=new ArrayList<>(colCnt);
      for (int i=1; i <= colCnt; i++)       row.add(rs.getObject(i));
      res.add(row);
    }
  }
  finally {
    U.closeQuiet(rs);
  }
  return res;
}

private static List < List < ? > > executeH2Query ( String sql , Object [ ] args ) throws SQLException { List < List < ? > > res = new ArrayList < > ( ) ; ResultSet rs = null ; try ( PreparedStatement st = conn . prepareStatement ( sql ) ) { for ( int idx = 0 ; idx < args . length ; idx ++ ) st . setObject ( idx + 1 , args [ idx ] ) ; rs = st . executeQuery ( ) ; ResultSetMetaData meta = rs . getMetaData ( ) ; int colCnt = meta . getColumnCount ( ) ; while ( rs . next ( ) ) { List < Object > row = new ArrayList < > ( colCnt ) ; for ( int i = 1 ; i <= colCnt ; i ++ ) row . add ( rs . getObject ( i ) ) ; res . add ( row ) ; } } finally { U . closeQuiet ( rs ) ; } return res ; }
execute sql query on h2 database .
