-2

I'm working on a project that involves 2 separate db to generate the report. The result of one is passed into the other query and a final report is generated. Now, i wan to sort the final report but having issues with it. Java constructor for "java.util.Arrays" with arguments "" not found.

var fist = new java.util.Arrays();
var list = new java.util.ArrayList();
var gist = new java.util.ArrayList();
var arr = '';

var dbConn = DatabaseConnectionFactory.createDatabaseConnection('Postgres connection');
var result3 = dbConn.executeCachedQuery(...)

while (result3.next()) {
    var value1 = result3.getString(1);
    var value2 = result3.getString(2);
    var dbConn3 = DatabaseConnectionFactory.createDatabaseConnection('Oracle connection'));
var result2 = dbConn3.executeCachedQuery("SELECT name FROM producer WHERE send = '" + value1 + "' AND code = '" + value2 + "' ORDER BY name")

while (result2.next()) {
    var sending = result2.getString(1);
}
dbConn3.close();
if (sending != undefined) {
    arr += gist.add(sending);
    arr += gist.add(value1);
    arr += gist.add(value2);
    arr += gist.add(result3.getString(3));
    fist.add(arr);
}
}
Arrays.sort(fist); //i'm thinking this should sort it before displaying it
while (fist.next()) {
    xmlMs += "<tr>"
    xmlMs += "<td>" + sending + "</td>";
    xmlMs += "<td>" + value1 + "</td>";
    xmlMs += "<td>" + value2 + "</td>";
    xmlMs += "<td align='center'>" + result3.getString(3) + "</td>";
    xmlMs += "</tr>";
}
austin wernli
  • 1,801
  • 12
  • 15
DiD
  • 77
  • 1
  • 11

2 Answers2

0

Well yes, your compiler is telling you that var fist = new java.util.Arrays(); is invalid, java.util.Arrays doesn't provide a public no-args constructor. Did you by chance mean ArrayList instead of Arrays?

kjosh
  • 587
  • 4
  • 11
0

Arrays doesn't have a constructor defined in the source code, so new Arrays(); causes the compiler to scream at you.

If you want an array of something you use

type[] varname = new type[size];

Note that the [] is what makes it an Array.

Ex:

int[] x = new int[5];

That will hold an array of 5 ints.

Aify
  • 3,543
  • 3
  • 24
  • 43
  • When i used ArrayLists() instead of Arrays(), i got similar error message. So are you suggesting something like this? String[] gist = new String[4] – DiD Feb 17 '15 at 22:13
  • There's a ton of errors in your code. For example, I'm pretty sure you cant use "var" as the type declaration. Arraylists also typically need to have a type – Aify Feb 17 '15 at 22:15
  • The var works fine except for the fist that i just included in my code. Everything works but the issue starts from the sort line. – DiD Feb 17 '15 at 22:18
  • Wheres your console output? – Aify Feb 17 '15 at 22:18
  • What do you mean by console output, the result is displayed in a table but i have to sort it before displaying the result. – DiD Feb 17 '15 at 22:20
  • Stacktrace? Don't have one? You said you got an error message – Aify Feb 17 '15 at 22:21
  • Do you mean the code above had no error(s) when you ran the script? – DiD Feb 17 '15 at 22:25
  • I'm not going to run your code. Post the stacktrace. – Aify Feb 17 '15 at 22:44