• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Database to multi-dimensional array problem

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to populate a multidimensional array with the number of records in a database that correspond to various application types. for some reason, i'm only getting values for the second row of the array....
If this description is vague, i apologize.
here is my code:

<%
String appYear = request.getParameter("appyear");
String[] appName = { "Deposit Account App", "Loans", "Small Business Deposit" };
String[] Month = { "01","02","03","04","05","06","07","08","09","10","11","12" };
int[][] monthlyTotal = new int[3][12];
int[] yearlyTotal = new int[3];
int[] monthlyAggregate = new int[12];
int ytdTotal = 0;

for(int i=0; i<appName.length; i++)
for(int j=0; j<Month.length; j++)
{
String query = "SELECT COUNT (*) FROM DBO.APPTRACK WHERE DATEPART(yyyy, LAST_MODIFIED) = " + appYear + "AND DATEPART(mm, LAST_MODIFIED) = " + Month[j] + " AND APPLICATION_NAME LIKE '" + appName[i] + " %'";
String[][] strResult = com.thebank.util.dbAgent.selectIntoArray(query);
int intResult = Integer.parseInt(strResult[1][0]);
//[1][0] b/c 1st row in db is field names
monthlyTotal[i][j] = intResult;
yearlyTotal[i] += monthlyTotal[i][j];
monthlyAggregate[j] += monthlyTotal[i][j];
ytdTotal += yearlyTotal[i];

}
%>
[ June 04, 2004: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing to do with JSP really, so I'm moving this off to the JDBC forum.

P.S. Also "need help" isn't a very good topic title so I've adjusted it for you.
 
reply
    Bookmark Topic Watch Topic
  • New Topic