카테고리 없음

MySQL Cannot Convert Value '0000-00-00 00:00:00' From Column XX To TIMESTAMP

[czar] 2011. 3. 4. 09:55

[MySQL] Cannot convert value '0000-00-00 00:00:00' from column 6 to TIMESTAMP



When I first started using the MySQL database engine, I would get this error from time to time after doing data transfer:

MySQL Cannot Convert Value '0000-00-00 00:00:00' From Column XX To TIMESTAMP

For a long time, I just assumed that I was messing something up in the data transfer (which I may very well have been doing). But then, I got it again last week on an existing database with a new ColdFusion datasource, so I figured I'd Google what was going on. Luckily, Andy Jarrett had the answer on hand; I needed to modify the connection string of the ColdFusion MySQL datasource to include:

zeroDateTimeBehavior=convertToNull

Here is a screen shot of this activity:


 
 
 

 
MySQL Datasource Connection String Update To Handle Error: MySQL Cannot Convert Value '0000-00-00 00:00:00' From Column XX To TIMESTAMP.  
 
 
 

I don't know how the zero dates get into the database in the first place (why NULL dates were not stored), but at least I know how to deal with this corrupt data.



timestamp 형식의 컬럼이 0000-00-00 00:00:00으로 초기화 되거나, 이와 같은 값을 입력 했을때

java에서 select시 발생함.


jdbc 연결 url에 zeroDateTimeBehavior=convertToNull를 추가한다.


jdbc:mysql://server/dbname?zeroDateTimeBehavior=convertToNull