-
1. Re: Timesone issues for java.util.Date persistence in MySQL?
joelvogt Oct 2, 2002 12:16 AM (in response to madalin)Remember the first fule for timezones in java is to just go sshhhh, and then hope nobody every notices.
But failing that, is there a reason why you don't map sql type TIMESTAMP? Give this a go.
Otherwise just check what time your system is running at v jboss. -
2. Re: Timesone issues for java.util.Date persistence in MySQL?
madalin Oct 4, 2002 6:12 AM (in response to madalin)Hi,
I am using Jboss 3.0.3 with Tomcat4.1.12 with MySQL 3.23.38, all of them on the same machine(XP). I am using the mapping described before (with java.util.Date) due to the Timestamp bug of setting the current date instead an intended one. I tested with the current date too (something like:
--------------------------
try {
archiveInfoLocal = archiveInfoLocalHomeRef.create(1);
} catch(CreateException e) {
throw new EJBException( e );
}
archiveInfoLocal.setStartTime(new Date());
---------------------------
and I checked the mySQL log and it receiving the datetime off with one hour.
Any ideeas please? There are no decent methods to store in mySQL a simple dateTime?
Best Regards,
Madalin -
3. Re: Timesone issues for java.util.Date persistence in MySQL?
joelvogt Oct 15, 2002 9:00 PM (in response to madalin)just to amend my previous post, using TIMESTAMP seems to cause update problems so your best to not do so
-
4. Re: Timesone issues for java.util.Date persistence in MySQL?
aloubyansky Oct 16, 2002 2:54 AM (in response to madalin)What problems?
-
5. Re: Timezone issues for java.util.Date persistence in MySQL?
madalin Oct 21, 2002 2:45 PM (in response to madalin)Hi,
Even if I am usign the normal mapping of java.sql.Timestamp
<java-type>java.sql.Timestamp</java-type>
<jdbc-type>TIMESTAMP</jdbc-type>
<sql-type>TIMESTAMP</sql-type>
I get the same result: the datetime is off by one hour.
Best Regards,
Madalin. -
6. Re: Timezone issues for java.util.Date persistence in MySQL?
joelvogt Oct 21, 2002 9:21 PM (in response to madalin)I'm not sure about timezone issues, but with mysql you should be aware that when you have a timestamp field, and then run an update on that table without setting a value for that field, then the timestamp field will automatically revert to the current time.
For example
create table test (name varchar(200), time TIMESTAMP(14));
insert into test values('fred','20041022102747');
update test set name='tom';
The value of time will now be the current time.
Note that this apparently only happens for the FIRST timestamp column in a mysql table.
This is a problem in the 2.4.x series. I am not sure about 3.x.y. Can someone confirm if it is or not?
Now there may be settings or workarounds in code and mysql, but it's certainly something to know as it caused me a few headaches before I worked out what was going on. -
7. Re: Timezone issues for java.util.Date persistence in MySQL?
madalin Oct 22, 2002 9:11 PM (in response to madalin)Hi,
Yes, I am aware of that. The database columns are of type DATETIME, because I want to avoid the TIMESTAMP automatic update issue. My impresion is it is something off in the mapping. Before I am writing the datetime value in the database, I am scheduling an event also, using the same datetime value. The event is fired at the right time, the value persisted in database is off by one hour...Of, it is killing me:)
Madalin. -
8. Re: Timezone issues for java.util.Date persistence in MySQL?
joelvogt Oct 22, 2002 10:00 PM (in response to madalin)Have you checked which timezone mysql is running at? Do a 'show variables' and just make sure it is the same as your os. Also a good idea to do a system out of what jboss is running at too.
-
9. Re: Timezone issues for java.util.Date persistence in MySQL?
madalin Oct 24, 2002 12:45 PM (in response to madalin)Hi,
All of them are running on the same machine:(, and the timezone is PDT (MySQL and OS). I am out of ideas :(((
Best Regards,
Madalin. -
10. Re: Timezone issues for java.util.Date persistence in MySQL?
scoy Oct 27, 2002 7:41 PM (in response to madalin)Hi,
I observed this problem on Saturday when running the JBoss 3.0 testsuite with mysql.
However, I then downloaded the mysql JDBC driver from http://www.mysql.com/downloads/api-jdbc-stable.html and the timezone problem went away.
So, make sure that you are using the current JDBC driver
Steve Coy -
11. Re: Timezone issues for java.util.Date persistence in MySQL?
madalin Oct 29, 2002 12:59 PM (in response to madalin)Great! Thank You very much, it is working now! That was the problem! I was using a MySQL driver version 2.0.11; when I replaced with a 2.0.14 version, the error gone.
Thank You again!
I hope next time I will not forget to get the latest driver or patch:)
Madalin.