I am using JDBC to query a MySQL database for specific records from two tables.
My MySQL query sample is this:
SELECT
r.name
, r.network
, r.namestring
, i.name
, r.rid
, i.id
, d.dtime
, d.ifInOctets
FROM router AS r
INNER JOIN interface AS i
ON r.rid = i.rid
INNER JOIN 1278993600_1_60 AS d
ON i.id = d.id
AND dtime BETWEEN 1279027200 AND 1279029000
WHERE r.network = "ITPN"
AND i.status = "active"
WHERE i.id BETWEEN 1418 AND 1518
Now is it possible for me to add all the specific records which I need:
r.name
, r.network
, r.namestring
, i.name
, r.rid
, i.id
, d.dtime
, d.ifInOctets
to an array specifically and print it out to an excel sheet?
I tried creating different classes for the 3 tables: r
, i
, d
. Then as I queried the database I created objects and added them to ArrayList
s, which I printed out to a different sheet. (The goal is to print it out to an excel sheet)
But this method is making me store and iterate over millions of objects.
Is there any method to add all records dynamically in an easier less time consuming way and send it to the sheet?