read-only + writable DAOs (scaling, database replication)

Let's assume I have the following database configuration:

-1 Master Database

-2 Replicated Databases (from Master)

Do I have two types of DAOs? One that's writable (accessing master) and one that's read-only for access to replicated DBs?

E.g.

WritableFooDAO

ReadOnlyFooDAO

*** OR ***

How about getting the connection based on the type of operations. E.g.

void getConnection(boolean writable);

UPDATE/CREATE: getConnection(true);

SELECT: getConnection(false);

-> The getConnection() method would act as a proxy returning a connection from the master / replicated database depending if a read-only connection for SELECT statements was requested.

x

[736 byte] By [mhhdudua] at [2007-11-26 14:59:40]
# 1
That depends on business rules and what you mean by "replicated".Typically a replicated database means that you completely ignore the fact that other databases exist. The replication is handled at the database level and has nothing to do with the applications that access it.
jschella at 2007-7-8 8:48:30 > top of Java-index,Other Topics,Patterns & OO Design...
# 2
That's correct, replication is on the database level to achieve load balancing. The question is, how to access those replicated databases from a programming point of view?
mhhdudua at 2007-7-8 8:48:30 > top of Java-index,Other Topics,Patterns & OO Design...
# 3

> That's correct, replication is on the database level

> to achieve load balancing. The question is, how to

> access those replicated databases from a programming

> point of view?

It might help to know why you want this.

If you need to manage each individual database then all you need to know is that it is just another connection.

Load balancing often means an actual load balancer though along with a virtual IP type arrangement. That means that you can't connect via that IP. You would need another IP (unique for each server) to connect to.

If on the other hand you are attempting to do the load balancing yourself then you need to implement that via code. That has nothing to do with the connection itself.

jschella at 2007-7-8 8:48:30 > top of Java-index,Other Topics,Patterns & OO Design...