Java server will start read / write to a new DB table every
week/monday
e.g.
table-1-2-2012
table-1-9-2012
table-1-16-2012
table-1-23-2012 ... etc
I think of 2 ways to do the DB table rotation
1) check the server timestamp, if today's date is week of 1-23-2012,
then read/write to table-1-23-2012
2) have a unix cron job run every monday to generate a text file on
Java server with DB table named on that date - on each Java request,
check the text file's table name - then read/write to that DB table
any other solution to DB table rotation?
Others have already harped on the poor design ... so I'll just address
the question as asked.
1) You don't say what DBMS, but most workgroup and enterprise level
implementations include a built in task scheduler. You can create a
internal task that runs at a specific time to create new tables.
2) Since you are load balancing, you are (or should!) be using
replication to keep the database instances synchronized. If you are
doing online (hot) replication, then creating a new table on one
server will replicate it on the other servers within a minute or so.
If, OTOH, replication is periodic, you can kick start it after
creating the new table.
3) You can designate one server as a master and have it remotely
create tables on the other servers. This also can be done with a DBMS
task. Of course, this introduces failover issues, i.e. what to do if
the master DBMS instance is down.
Clients do not need to know about or participate in this table
rotation scheme at all. They can use the same table all the time.
Periodically the contents of the table can be copied into a dated
archive table and then the current use table can be emptied.
This is a simple 2 step transaction:
SELECT INTO <archival table> * FROM <current table>;
DELETE FROM <current table>;
George