Clojure / postgresql:当db中有错误时,如何看到异常? [英] Clojure/postgresql: How do I see the exception when an error is in the db?

查看:189
本文介绍了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的链接,显示如何使用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中有错误时,如何看到异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆