java - exporting data into double array -


i want add retrieved data database array, retrieval data null. mistake? please me.

for (user u : userlists) {             (resource r : resourcelists) {                  string ratingquery                         = "select rank ratings userindex='"                         + u.getindex()                         + "' , resourceindex='"                         + r.getindex()                         + "'";                  try {                     ratingcon = connectionmanager.getconnection();                     stmt = ratingcon.preparestatement(ratingquery);                     rs = stmt.executequery();                      while (rs.next()) {                     rate = rs.getdouble("rank");                     ratings[u.getindex()][r.getindex()] = rate; //it seems here problem                     }                  } catch (exception e) {                     system.out.println("log in failed: exception has occurred! " + e);                 }             }         } 

there no problem in line, if ratings 2-dimensional array of double:

ratings[u.getindex()][r.getindex()] = rate; 

but may database returns empty resultset? insert print statement debug:

  while (rs.next()) {       rate = rs.getdouble("rank");        system.out.println("result set not empty! current rank is: " + rate);       ratings[u.getindex()][r.getindex()] = rate; //it seems here problem   } 

if prints nothing - problem not in code in db data. think missed semicolon ; @ end of query.

and exception handling:

 catch (exception e) {      system.out.println("log in failed: exception has occurred! " + e);  } 

the exception type catch here abstract - can't know whether sqlexception exception or arrayindexoutofboundsexception. change several catch blocks.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -