Don't perform basic SQL tasks in code
Relational databases are a mature technology, and they should be used to do as much simple work as possible.
For example, don't do the following in code, if they can be done in SQL instead:
-
ordering (ORDER BY)
-
filtering based on criteria (WHERE)
- joining tables (WHERE, JOIN) -- see the code tables topic for a possible exception to this rule
-
summarizing (GROUP BY, COUNT, AVG, STDDEV)
Any corresponding task implemented by your own code would very likely:
- be much less robust and efficient
- take longer to implement
- require more maintenance effort
To retain the order of a ResultSet
as specified in ORDER BY, choose
a collection which has a defined iteration order, such as an ArrayList
or a LinkedHashMap
.
See Also :