db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Hiles <markahi...@fastmail.fm>
Subject Re: Re-using an existing db and archiving data
Date Wed, 19 Mar 2008 11:06:42 GMT
I did both ways of testing to see if my resultset is null, which it isn't.

I can't upload the actual class I'm working on, I don't want the uni to accuse
me of getting other people to do my code.. I'll type up something along the same
lines, if someone could point me in the right direction of what I'm doing wrong..

private ArrayList getSomeResults(String constraint) {
  ArrayList<ArrayList> outerArrLst = new ArrayList<ArrayList>();
  ArrayList<String> innerArrLst = new ArrayList<String>();

  try {
    rs = stmt.executeQuery("select field1, field2 from tablename where field3 =
'" + constraint + "'");

    while(rs.next()) {
            innerArrLst.add(rs.getString("field1"));
            innerArrLst.add(rs.getString("field2"));
            outerArrLst.add(innerArrLst);
    }
  } catch (Exception e) {e.printStackTrace();}

  rs.close();
  rs = null;

  return outerArrLst;
}


Mime
View raw message