解決提示Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp;的方法

來源:互聯網
上載者:User

標籤:插入   .sql   unicode   col   出錯   utf8   時間段   log   coding   

Mysql在進行查詢時報了一個

Value ‘0000-00-00 00:00:00‘ can not be represented as java.sql.Timestamp;

這樣的錯誤,這是因為在預設插入一個類型為timestamp的時間時它會將‘0000-00-00 00:00:00‘插入,但是在資料庫定義時又因為設計是非空的timestamp類型的時間,所以查詢時就會出錯,並且mysql的時間範圍是:‘1000-01-01 00:00:00‘ 到 ‘9999-12-31 23:59:59‘這個時間段,所以會報錯,目前的解決辦法是在jdbc串連檔案中添加一句:

&zeroDateTimeBehavior=convertToNull

 

url=jdbc:mysql://localhost:3306/seckill?useUnicode=true&characterEncoding=utf8&&zeroDateTimeBehavior=convertToNull

 

目前這個方法還是有用的,但是到了後邊不知道會不會會有新的問題出現。

 

解決提示Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp;的方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.