简体   繁体   中英

jdbc execute error when using clojure

The following link https://my.vertica.com/docs/6.0.x/HTML/index.htm#14874.htm mentioned we could use

boolean result = stmt.execute("COPY customers FROM "
                            + " '/data/customers.txt' DIRECT ENFORCELENGTH");

But it doesn't work in clojure

(clojure.java.jdbc/execute! vertica-db "copy customer1.stage_test_etl_195 from '/tmp/valid-197.csv' DELIMITER '|' DIRECT ENFORCELENGTH ")

ClassCastException java.lang.Character cannot be cast to java.lang.String  clojure.java.jdbc/prepare-statement (jdbc.clj:457)

Have a careful read of the clojure.jdbc documentation. The second argument to execute! should be a vector with the first element being the SQL and other (optional) parameters. The following may work

(clojure.java.jdbc/execute! vertica-db ["copy customer1.stage_test_etl_195 from '/tmp/valid-197.csv' DELIMITER '|' DIRECT ENFORCELENGTH "])

assuming that is a legal statement for the db backend

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM