File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Database to multi-dimensional array problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Database to multi-dimensional array problem" Watch "Database to multi-dimensional array problem" New topic

Database to multi-dimensional array problem

Bill Brasskey
Ranch Hand

Joined: Jun 01, 2004
Posts: 47
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

Joined: Jan 10, 2002
Posts: 63548

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.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Database to multi-dimensional array problem
It's not a secret anymore!