Question: 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.

```

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

Answer: 
See this [link on clojure/jdbc](http://en.wikibooks.org/wiki/Clojure_Programming/Examples/JDBC_Examples#Dropping_a_Table) showing how to drop a table with Clojure/JDBC.

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

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

```
(.printStackTrace (.getCause e))

```
I have used the following to drop/create tables successfully and to get accurate error information when postgresql gets upset:

```
(defn drop-table [name]
    (sql/with-connection db
      (with-open [s (.createStatement (sql/connection))]
        (try
          (.addBatch s (str "drop table " name ))
          (seq (.executeBatch s))
          (catch Exception _)))))

(defn setup []
  (comment "TODO: create tables here"))

(defn -main []
  (try
  (print "Dropping table...") (flush)
  (drop-table "table_name")
  (print "Creating database structure...") (flush)
  (setup)
  (println " done")
  (catch Exception e (.getNextException e))))

```