This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Database to multi-dimensional array problem  RSS feed

Bill Brasskey
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • 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 ]
Bear Bibeault
Author and ninkuma
Posts: 66203
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!