开发者

How to suppress exception logging for groovy DataSet operations?

I have some groovy code like this:

    def dest = destSql.dataSet('destination_table')
    sourceSql.eachRow('select * from source_table'){row ->

        try {
            dest.add(ID: row.id)
        } catch (SQLException) { //A FK constraint will case some inserts to fail 
            dest.add(ID: 1)
        }
    }

I'm running this as a command line script. Everything works fine, but the console outputs the SQLExceptions no mat开发者_JAVA技巧ter what. I'd like them to not show up when I handle them, as they only pollute the output. How could I specify this (programmatically, if possible)?

TIA.


You probably just want to turn down the logging level of groovy sql. Try putting this in your program before you try adding to the dataset:

Sql.LOG.level = java.util.logging.Level.SEVERE


Isn't adding something (possibly multiple times) with ID:1 going to fire a fk constraint exception?

It's probably this exception you are seeing, not the one you're catching.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜