9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

DataSourceにzeroDateTimeBehaviorプロパティを渡す

Last updated at Posted at 2014-04-24

java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.timestamp
なエラーがでた場合にデータの代わりに NULL を戻してExceptionを回避する

JDBCのURLで

jdbc:mysql://localhost:3306/mydb?user=mydb&password=mydb&zeroDateTimeBehavior=convertToNull

と渡せるが、この情報をDataSourceで管理するときは
dataSource.setConnectionPropertiesの引数で渡す
引数はStringで、「propatyName=value;」のフォーマットで渡す。

BasicDataSource dataSource = new BasicDataSource();
dataSource.setConnectionProperties("zeroDateTimeBehavior=convertToNull;");
9
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?