本文介绍了Clojure / postgresql:当db中有错误时,如何看到异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用clojure和postgresql时,每当我发出的语句以某种方式格式化或者被数据库本身拒绝时,我得到类似以下错误:

When using clojure with postgresql, whenever a statement I issue is malformed in some way or otherwise rejected by the db itself I get something like the following error:

java.sql.BatchUpdateException: 
  Batch entry 0 drop schema public cascade was aborted.  
  Call getNextException to see the cause.

如何调用getNextException以便我可以看到我做错了什么?我从哪里调用它?

How can I call getNextException so that I can see what I did wrong? Where do I call it from?

推荐答案

查看此,显示如何使用Clojure / JDBC删除表。

See this link on clojure/jdbc showing how to drop a table with Clojure/JDBC.

使用try catch块来处理错误。

It also shows you how to handle errors with a try catch block.

在try catch块中,您可以编写类似的内容:

From within that try catch block, you can write something similar to:

(.printStackTrace (.getCause e))

这篇关于Clojure / postgresql:当db中有错误时,如何看到异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 07:02