Kees deVries wrote:use this to get all the table numbers.
I also have a few remarks about the overall quality of your code.
First of all, I don't get why the
selectOrder method has to throw
ClassNotFoundException I assume it is probably because of the call to
super.getConnection(). It's probably because in that method you have something like
If you are using a
JDBC 4.0 compliant driver, you no longer need to explicitly load JDBC drivers using
Class.forName(). The JDBC drivers are automatically loaded during initialitzation, thanks to the
Java SE Service Provider mechanism (SPM). So you can remove this line from this method (and remove the
throws clause as well) and the code will still work as intended.
Secondly you should not have code like this
Because this code exposes an implementation detail (the class
Order has probably a
List of
OrderProducts) and makes it harder to refactor the code. For example, if you need to change the type of the
orderProducts property to an array or a
Map, this code fails to compile and you need to update this code as well. It is much better to define a method
addOrderProducts (or
addProducts)) and this method takes care of adding the products. Using this approach you are not exposing any implementation details and if you need to change the type of the
orderProducts property to e.g. a
Map, you only need to change this method (and not the method in your DAO class).
And then in the
selectOrder method you can simply invoke this method
Hope it helps!
Kind regards,
Roel