Methods Accessing quesstion
Hi all ,
my application can work with several db back-ends (MySQL,ORacle ...)
so the structure at high level has the following 3 layers:
GUI - Intermediate DB class - MySQL DB classes, Oracle DB classes ...
My Intermediate DB class , depending on a .ini variable, selects the appropiate MYSQL or Oracle method
How can I avoid accessing to MySQL/Oracle methods directly from the GUI without passing through the intermediate class?
MySQL and Oracle methods are in different .java...
Thanks!
[538 byte] By [
tlloretia] at [2007-11-27 10:40:30]

Uh, why is the GUI accessing the persistency layer in the first place?
And it's hard to tell what you can do since I don't know what these methods are doing.
Anyway, I don't see why one can't do something like make both "special" classes implement the same interface, load them by name and just work on the very same reference. After all, the method's implementation might change, but the methods declarations shouldn't really. If so, you might have a quite weird design.
So, if I well understood, the intermediate layer should be an interface and MySQL_DB_methods and ORacle_DB_methods should implement these methods isnt it?
E.g. MySQL_DB_methods.createNewUser(UserBean user)
Oracle_DB_methods.createNewUser(UserBean user)
but this method createNewUser should be public isnit? so I can access also from GUI which is the situation i want to avoid ....
Thanks!
> So, if I well understood, the intermediate layer
> should be an interface and MySQL_DB_methods and
> ORacle_DB_methods should implement these methods isnt
> it?
>
> E.g. MySQL_DB_methods.createNewUser(UserBean user)
> Oracle_DB_methods.createNewUser(UserBean user)
>
> but this method createNewUser should be public isnit?
> so I can access also from GUI which is the situation
> i want to avoid ....
>
> Thanks!
No. Why bother with these RDBMS-specific methods at all? JDBC doesn't do that, so why do you? The point Rene is making is, your UI layer should not be aware of the underlying data access technology, this is the essence of the DAO pattern. You seem to be going to some lengths to couple your app. to a particular database, whereas everyone else in the world goes in the other direction