aspose file tools*
The moose likes JDBC 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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Database to multi-dimensional array problem" Watch "Database to multi-dimensional array problem" New topic
Author

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
Marshal

Joined: Jan 10, 2002
Posts: 61043
    
  66

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] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Database to multi-dimensional array problem