Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Java DB rotation

Reply
Thread Tools

Java DB rotation

 
 
Jim Lee
Guest
Posts: n/a
 
      01-31-2012
I have a Java server controller that read/write to Database table

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 corn 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?

the first way check timestamp have a drawback when server's time is
not set to correct time, since

there are many Java server running for load balance, it's not a good
idea.

the second way is a better solution, but request additional setup -
cron job
 
Reply With Quote
 
 
 
 
Arne Vajhøj
Guest
Posts: n/a
 
      01-31-2012
On 1/30/2012 9:08 PM, Jim Lee wrote:
> I have a Java server controller that read/write to Database table
>
> 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 corn 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?
>
> the first way check timestamp have a drawback when server's time is
> not set to correct time, since
>
> there are many Java server running for load balance, it's not a good
> idea.
>
> the second way is a better solution, but request additional setup -
> cron job


I can not see any any problems with construction the table
name every time you need it.

That string formatting will be insignificant compared to
the actual database operation.

And it will be far more expensive to read from a file.

So definitely #1.

Arne

 
Reply With Quote
 
 
 
 
Arne Vajhøj
Guest
Posts: n/a
 
      01-31-2012
On 1/30/2012 9:12 PM, Arne Vajhøj wrote:
> On 1/30/2012 9:08 PM, Jim Lee wrote:
>> I have a Java server controller that read/write to Database table
>>
>> 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 corn 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?
>>
>> the first way check timestamp have a drawback when server's time is
>> not set to correct time, since
>>
>> there are many Java server running for load balance, it's not a good
>> idea.
>>
>> the second way is a better solution, but request additional setup -
>> cron job

>
> I can not see any any problems with construction the table
> name every time you need it.
>
> That string formatting will be insignificant compared to
> the actual database operation.
>
> And it will be far more expensive to read from a file.
>
> So definitely #1.


But also consider if you really want to switch table like
that.

Why not just use the same table all the time with a column
for the period?

For most cases that would be the best solution. Exceptions
do exist.

Arne
 
Reply With Quote
 
Jim Lee
Guest
Posts: n/a
 
      01-31-2012
On Mon, 30 Jan 2012 21:12:14 -0500, Arne Vajh?j <>
wrote:

>On 1/30/2012 9:08 PM, Jim Lee wrote:
>> I have a Java server controller that read/write to Database table
>>
>> 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 corn 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?
>>
>> the first way check timestamp have a drawback when server's time is
>> not set to correct time, since
>>
>> there are many Java server running for load balance, it's not a good
>> idea.
>>
>> the second way is a better solution, but request additional setup -
>> cron job

>
>I can not see any any problems with construction the table
>name every time you need it.


to construct the table name, i need to use the server timestamp, what
if the server time is incorrect? then everything is messed up? On
linux, is the server time always in sync with internet time server? or
it's depended on the motherboard BIOS time?

>
>That string formatting will be insignificant compared to
>the actual database operation.
>
>And it will be far more expensive to read from a file.
>
>So definitely #1.
>
>Arne


 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      01-31-2012
On 1/30/2012 9:17 PM, Jim Lee wrote:
> On Mon, 30 Jan 2012 21:12:14 -0500, Arne Vajh?j<>
> wrote:
>
>> On 1/30/2012 9:08 PM, Jim Lee wrote:
>>> I have a Java server controller that read/write to Database table
>>>
>>> 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 corn 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?
>>>
>>> the first way check timestamp have a drawback when server's time is
>>> not set to correct time, since
>>>
>>> there are many Java server running for load balance, it's not a good
>>> idea.
>>>
>>> the second way is a better solution, but request additional setup -
>>> cron job

>>
>> I can not see any any problems with construction the table
>> name every time you need it.

>
> to construct the table name, i need to use the server timestamp, what
> if the server time is incorrect? then everything is messed up? On
> linux, is the server time always in sync with internet time server? or
> it's depended on the motherboard BIOS time?


If you can not get the time correctly to construct a tablename
then you can not get the time correctly to write to the file.

You can setup NTP to synch time.

But does it matter if one server is 2 seconds off?

Arne


 
Reply With Quote
 
Jim Lee
Guest
Posts: n/a
 
      01-31-2012
On Mon, 30 Jan 2012 21:14:21 -0500, Arne Vajh?j <>
wrote:

>On 1/30/2012 9:12 PM, Arne Vajh?j wrote:
>> On 1/30/2012 9:08 PM, Jim Lee wrote:
>>> I have a Java server controller that read/write to Database table
>>>
>>> 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 corn 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?
>>>
>>> the first way check timestamp have a drawback when server's time is
>>> not set to correct time, since
>>>
>>> there are many Java server running for load balance, it's not a good
>>> idea.
>>>
>>> the second way is a better solution, but request additional setup -
>>> cron job

>>
>> I can not see any any problems with construction the table
>> name every time you need it.
>>
>> That string formatting will be insignificant compared to
>> the actual database operation.
>>
>> And it will be far more expensive to read from a file.
>>
>> So definitely #1.

>
>But also consider if you really want to switch table like
>that.
>
>Why not just use the same table all the time with a column
>for the period?
>
>For most cases that would be the best solution. Exceptions
>do exist.
>
>Arne




I must use a new table
 
Reply With Quote
 
Martin Gregorie
Guest
Posts: n/a
 
      01-31-2012
On Mon, 30 Jan 2012 18:08:04 -0800, Jim Lee wrote:

> I have a Java server controller that read/write to Database table
>
> 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
>

What problem are you using table rotation to solve?

What would prevent you from using a single table containing datestamped
rows which are archived and/or deleted the rows after "cycle length" days?


--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
 
Reply With Quote
 
Jim Lee
Guest
Posts: n/a
 
      01-31-2012
1-2 sec off is not matter


On Mon, 30 Jan 2012 21:20:14 -0500, Arne Vajh?j <>
wrote:


>On 1/30/2012 9:17 PM, Jim Lee wrote:
>> On Mon, 30 Jan 2012 21:12:14 -0500, Arne Vajh?j<>
>> wrote:
>>
>>> On 1/30/2012 9:08 PM, Jim Lee wrote:
>>>> I have a Java server controller that read/write to Database table
>>>>
>>>> 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 corn 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?
>>>>
>>>> the first way check timestamp have a drawback when server's time is
>>>> not set to correct time, since
>>>>
>>>> there are many Java server running for load balance, it's not a good
>>>> idea.
>>>>
>>>> the second way is a better solution, but request additional setup -
>>>> cron job
>>>
>>> I can not see any any problems with construction the table
>>> name every time you need it.

>>
>> to construct the table name, i need to use the server timestamp, what
>> if the server time is incorrect? then everything is messed up? On
>> linux, is the server time always in sync with internet time server? or
>> it's depended on the motherboard BIOS time?

>
>If you can not get the time correctly to construct a tablename
>then you can not get the time correctly to write to the file.
>
>You can setup NTP to synch time.
>
>But does it matter if one server is 2 seconds off?
>
>Arne
>

 
Reply With Quote
 
Jim Lee
Guest
Posts: n/a
 
      01-31-2012
On Tue, 31 Jan 2012 02:21:11 +0000 (UTC), Martin Gregorie
<> wrote:

>On Mon, 30 Jan 2012 18:08:04 -0800, Jim Lee wrote:
>
>> I have a Java server controller that read/write to Database table
>>
>> 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
>>

>What problem are you using table rotation to solve?
>
>What would prevent you from using a single table containing datestamped
>rows which are archived and/or deleted the rows after "cycle length" days?


my main problem is how to make sure "how to get the correct table name
to read/write to" depending what day in the week

start a new DB table is a must since it's going through some other
REST backend layer
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      01-31-2012
On 1/30/2012 9:23 PM, Jim Lee wrote:
> On Mon, 30 Jan 2012 21:20:14 -0500, Arne Vajh?j<>
> wrote:
>> On 1/30/2012 9:17 PM, Jim Lee wrote:
>>> On Mon, 30 Jan 2012 21:12:14 -0500, Arne Vajh?j<>
>>> wrote:
>>>
>>>> On 1/30/2012 9:08 PM, Jim Lee wrote:
>>>>> I have a Java server controller that read/write to Database table
>>>>>
>>>>> 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 corn 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?
>>>>>
>>>>> the first way check timestamp have a drawback when server's time is
>>>>> not set to correct time, since
>>>>>
>>>>> there are many Java server running for load balance, it's not a good
>>>>> idea.
>>>>>
>>>>> the second way is a better solution, but request additional setup -
>>>>> cron job
>>>>
>>>> I can not see any any problems with construction the table
>>>> name every time you need it.
>>>
>>> to construct the table name, i need to use the server timestamp, what
>>> if the server time is incorrect? then everything is messed up? On
>>> linux, is the server time always in sync with internet time server? or
>>> it's depended on the motherboard BIOS time?

>>
>> If you can not get the time correctly to construct a tablename
>> then you can not get the time correctly to write to the file.
>>
>> You can setup NTP to synch time.
>>
>> But does it matter if one server is 2 seconds off?

>
> 1-2 sec off is not matter


Synching time today is not difficult.

Arne

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PTK Rotation in WPA-PSK and WPA2-PSK =?Utf-8?B?c2xhbWI=?= Wireless Networking 0 09-22-2005 09:09 PM
Java 2D: Image rotation Mark via JavaKB.com Java 0 03-19-2005 06:40 AM
Why is lossless rotation actually gainful rotation? Louise Digital Photography 19 02-02-2004 08:37 AM
TKIP vs Broadcast Key Rotation Mike Cisco 0 11-23-2003 02:14 AM
360degree rotation in Java2D Will Clark Java 3 09-04-2003 04:30 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57