Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / March 2006

Tip: Looking for answers? Try searching our database.

MySQL DATETIME conversion errors?

Thread view: 
Cédric Pillonel - 30 Mar 2006 15:13 GMT
I do the following in my java application:

Statement s = myConnection.createStatement();
ResultSet rs = s.executeQuery("SELECT startTime FROM MyTable WHERE
_rowid=1");
if (rs.next())
{
java.sql.Timestamp stamp = (java.sql.Timestamp)rs.getObject(1);
String startTime = stamp.toString();
}

I get the following value in startTime: "2006-03-02 12:00:00.0"
But in the database is the following value stored: "2006-02-30 12:00:00.0"

I am running MySQL 4.1.12 on RedHat Linux ES 4.0 EMT64.
I run my java application on Windows 2000 with java 1.5.0_03-b07 and
mysql-connector-java-3.1.12. I have also tried
mysql-connector-java-5.0.0-beta, same problem.

Any idea?
Thank you.
scoffer - 31 Mar 2006 14:03 GMT
Hi,

try with:

Statement s = myConnection.createStatement();
ResultSet rs = s.executeQuery("SELECT startTime FROM MyTable WHERE
_rowid=1");
if (rs.next())
{
java.sql.Date stamp = rs.getDate(1);
String startTime = stamp.toString();
}

>I do the following in my java application:
>
[quoted text clipped - 17 lines]
> Any idea?
> Thank you.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.