Bug #12994 mysql-connector-java-3.1.10-bin returns wrong Timestamp(14) format?!
Submitted: 5 Sep 2005 14:28 Modified: 6 Sep 2005 0:28
Reporter: Jeppe Skovbon Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:mysql-connector-java-3.1.10-bin OS:Windows (Windows XP)
Assigned to: CPU Architecture:Any

[5 Sep 2005 14:28] Jeppe Skovbon
Description:
I use mysql-4.0.25-win32.

I have a column in my database with the Datatype called Timestamp(14).

When I use the driver: mysql-connector-java-3.0.15-ga-bin, and try to get the Timestamp as following:

String jobStartTimestamp = rs.getString("jobStartTimestamp");

 - I have no problems. When I print out the String jobStartTimestamp I get the format: 20050905120000, as expected.

But when I use the the driver: mysql-connector-java-3.1.10-bin, I recieve the Timestamp format as 2005-09-05 12:00:00.0

Is that a bug or do I have to change all my code?

How to repeat:
Create the table:

CREATE TABLE `job` (
  `jobID` int(11) NOT NULL auto_increment,
  `jobName` varchar(100) NOT NULL default '',
  `jobClass` varchar(100) NOT NULL default '',
  `jobStartTimestamp` timestamp(14) NOT NULL,
  `jobRollTimestamp` timestamp(14) NOT NULL default '00000000000000',
  `jobRoll` int(11) NOT NULL default '0',
  `jobRollCounter` int(11) NOT NULL default '0',
  `jobIsActive` tinyint(1) NOT NULL default '0',
  `compID` int(10) NOT NULL default '0',
  PRIMARY KEY  (`jobID`)
) TYPE=MyISAM;

//RUN THE QUERY

stat = conn.prepareStatement("SELECT job.jobID, job.jobClass, job.jobStartTimestamp,job.jobRollTimestamp, job.jobRoll, job.jobRollCounter,  job.jobIsActive FROM job");

rs = stat.executeQuery();
					     
while ( rs.next() ){
						   	 	   	
int jobID = rs.getInt("jobID");
String jobClass = rs.getString("jobClass");
String jobStartTimestamp = rs.getString("jobStartTimestamp");
String  jobRollTimestamp = rs.getString("jobRollTimestamp");
int jobRollTimeType = rs.getInt("jobRoll");
int jobRollCounter = rs.getInt("jobRollCounter");
int jobIsActive = rs.getInt("jobIsActive");				

}
rs.close();
[6 Sep 2005 0:28] Mark Matthews
The JDBC specification requires ResultSet.getString() to equal ResultSet.getObject().toString() , especially for the TIMESTAMP type, therefore Connector/J 3.1 implements this.

If you don't want this behavior, use the following property:

noDatetimeStringSync=true in your JDBC URL.