H2 Java Insert ignore - allow exception

不羁的心 提交于 2019-12-01 17:35:18

One solution is to use:

insert into test 
select 1, 'Hello' from dual 
where not exists(select * from test where id = 1)

This should work for all databases (except for the dual part; you may need to create your own dummy table with one row).

To disable logging exceptions, append ;trace_level_file=0 to the database URL:

jdbc:h2:~/test;trace_level_file=0

or run the SQL statement:

set trace_level_file 0
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!