In writing a relatively simple app, I was considering making a class that handled all the database interaction. I was going to construct all the prepared statements in the class. That way, any DB changes would (probably) only result in changes to that one class. (Also, it puts the DB user ID & password in one class.) For example, I was planning to write a class with a method to register the DB driver, another to make a connection, another to read, another to write, and yet another method to update.
Besides ease of maintaining the code, does this offer any other benefit? Maybe under a multithreaded context? Also, I was planning to passing as arguments to the query methods the variables to bind to the prepared statements. I was going to return the result set as an argument as well. Am I over thinking this? TIA.
vendredi 8 janvier 2016
Is it good form in Java to place your DB functions in dedicated class/methods?
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire