Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #11714

Re: Java DB rotation

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From George Neuner <gneuner2@comcast.net>
Newsgroups comp.lang.java.programmer
Subject Re: Java DB rotation
Date Thu, 02 Feb 2012 14:05:31 -0500
Organization A noiseless patient Spider
Lines 53
Message-ID <ojkli7pu87pc57guh7am8tlvkrmcrfhb7f@4ax.com> (permalink)
References <n7jei7582sh0m08frucvasubaaiplnvc2s@4ax.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
Injection-Info mx04.eternal-september.org; posting-host="lVf68t8uHmjdVz2XnYXQzA"; logging-data="24664"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/tolLzBKkk+02cmt3Go6pFgq6HdBYFLPk="
X-Antivirus-Status Clean
X-Newsreader Forte Agent 3.2/32.830
X-Antivirus avast! (VPS 120202-1, 02/02/2012), Outbound message
Cancel-Lock sha1:a12mWhyhfXCscnfNgcTg4eC9sQs=
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:11714

Show key headers only | View raw


On Mon, 30 Jan 2012 18:08:04 -0800, Jim Lee <jimlee2907@yahoo.com>
wrote:

>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

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Java DB rotation Jim Lee <jimlee2907@yahoo.com> - 2012-01-30 18:08 -0800
  Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-01-30 21:12 -0500
    Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-01-30 21:14 -0500
      Re: Java DB rotation Jim Lee <jimlee2907@yahoo.com> - 2012-01-30 18:20 -0800
        Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-01-30 21:34 -0500
        Re: Java DB rotation Robert Klemme <shortcutter@googlemail.com> - 2012-01-31 08:36 +0100
    Re: Java DB rotation Jim Lee <jimlee2907@yahoo.com> - 2012-01-30 18:17 -0800
      Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-01-30 21:20 -0500
        Re: Java DB rotation Jim Lee <jimlee2907@yahoo.com> - 2012-01-30 18:23 -0800
          Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-01-30 21:31 -0500
  Re: Java DB rotation Martin Gregorie <martin@address-in-sig.invalid> - 2012-01-31 02:21 +0000
    Re: Java DB rotation Jim Lee <jimlee2907@yahoo.com> - 2012-01-30 18:24 -0800
      Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-01-30 21:32 -0500
        Re: Java DB rotation Robert Klemme <shortcutter@googlemail.com> - 2012-01-31 08:38 +0100
          Re: Java DB rotation Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-01-31 12:57 -0600
            Re: Java DB rotation Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-01-31 13:03 -0600
              Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-01-31 20:32 -0500
                Re: Java DB rotation Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-02-01 13:49 -0600
                Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-02-01 19:23 -0500
            Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-01-31 20:31 -0500
          Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-01-31 20:30 -0500
  Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-01-30 21:35 -0500
    Re: Java DB rotation Lew <noone@lewscanon.com> - 2012-01-30 22:54 -0800
  Re: Java DB rotation George Neuner <gneuner2@comcast.net> - 2012-02-02 14:05 -0500
  Re: Java DB rotation Rajiv Gupta <rajiv@invalid.com> - 2012-02-08 02:08 +1100

csiph-web