Getting a date of the remote machine from a Java desktop application

N

nilangini

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
 
R

Roedy Green

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.
 
R

Roedy Green

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.
 
M

Malte

nilangini said:
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

Dunno Access, but most real rdbms systems understand sysdate from a
stored procedure. We use it all the time for Oracle.
 
H

HalcyonWild

Malte said:
nilangini wrote:

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.
 
N

nilangini

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
 
M

Malte

nilangini said:
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

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 ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top