I am writing a Java desktop application which accesses the
database from a remote server. We are using an MS Access database
residing on the remote server.
In some of the tables when a new record is inserted, we need to insert
the server date in one of the field (like CeationTimestamp). Currently,
whenever a new record is inserted, the client date and time goes in
this field.
Do you have any idea how to achieve this?
Thank you very much for your help,
Nilangini
Roedy Green - 27 Oct 2005 08:39 GMT
>Do you have any idea how to achieve this?
The problem is Access. There is no server program that even knows the
server's date. The database is just a just a shared file manipulated
independently by each client.
So I see two ways out .
1. get a real database that has a server process that knows the server
time. See http://mindprod.com/jgloss/sqlvendors.html
2. synchronise your clients to an atomic clock every day so their
clocks are not wildly out of sync. See
http://mindprod.com/webstarts/setclock.html
It is possible that MS is putting LOCAL time in the server rather than
UTC, harkening back to the days of Win98 where the OS kept only local
time. In that case, you would have to invent your own UTC time class
and figure out the value locally and store it in the database as a
long.
Or consider muddling along using local time if all clients are on the
same local time.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Gordon Beaton - 27 Oct 2005 09:08 GMT
> 2. synchronise your clients to an atomic clock every day
Do it (virtually) continuously, not once a day. Use ntp.
/gordon

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Roedy Green - 27 Oct 2005 10:34 GMT
>Do it (virtually) continuously, not once a day. Use ntp.
the code for doing that is in SetClock. They can cannibalise it to
fully automate the update or look for clock synching software that
does not require a fat Java JVM.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Malte - 27 Oct 2005 15:00 GMT
> I am writing a Java desktop application which accesses the
> database from a remote server. We are using an MS Access database
[quoted text clipped - 9 lines]
> Thank you very much for your help,
> Nilangini
Dunno Access, but most real rdbms systems understand sysdate from a
stored procedure. We use it all the time for Oracle.
HalcyonWild - 28 Oct 2005 01:20 GMT
> > In some of the tables when a new record is inserted, we need to insert
> > the server date in one of the field (like CeationTimestamp). Currently,
[quoted text clipped - 3 lines]
> Dunno Access, but most real rdbms systems understand sysdate from a
> stored procedure. We use it all the time for Oracle.
====
Go for MySql, it can run on windows systems. Why pay for something like
Access when mySql is available for download. And it supports the
current date time of the server. And I think it is better than Access,
as a DB system.
nilangini - 28 Oct 2005 05:00 GMT
Thank you all for the response.
My problem is I need to support Access for my application.
Isn't there anything which I can call from java program to query the
date from the remote machine? I can in turn pass that date to my Insert
query.
If setclock can read both server as well as client date, why can't my
program read the date from another machine?
I am sorry if I sound very silly, but I feel that there should be some
method or way to ask for the date from another computer.
Thanks a lot,
Nilangini
Malte - 28 Oct 2005 16:07 GMT
> Thank you all for the response.
> My problem is I need to support Access for my application.
[quoted text clipped - 9 lines]
> Thanks a lot,
> Nilangini
If you really, really want to you can write a small server program that
listens on a free port for a request from the client. It answers with
the sysdate from the server, sent as a String.
Not hard to do. Even cooler would be a small web service, but I am
probaly reaching here ;-)