Fork me on GitHub

I may open a bug with facebook then, as I can’t see a way around it for now


@nha That gist just shows calling bean fails -- that's unrelated to, right? What actual JDBC code is failing when you use Presto? And what is the stack trace?


It can fail for a number of reasons - bad query syntax, empty columns etc. (not at my computer to test at the moment). It doesn’t preclude using per se - but any error becomes an IllegalAccessException with little information attached.


I will see if I can get a more complete stacktrace at home. I don’t think it is related to other than it did pop up when trying to make presto work with clojure.


OK, thanks. Seeing the actual code and the actual stacktrace will really help.


here is the stacktrace Not very helpful as-is. I now remember digging and couldn’t find what was calling bean in the first place. As for the code, any “wrong” statement will do:

(println (jdbc/execute! sql-conn ["any rubbish will do;"]))


The exception is coming from Aviso's pretty-stack-printer, which is used by Boot to display an exception. I would try using clojure / clj and deps.edn here and see if you can get the raw stacktrace from the Presto failure instead. Or wrap your code in try/`catch` and call Throwable->map on the thrown exception and print it as raw data.


Also, which version of Java are you running this on?


Throwable->map seems like a reasonable workaround for now.

          ;; setting up the presto server is not something I can provide easily though
          (with-open [sql-conn (jdbc/get-connection (jdbc/get-datasource {:dbtype "presto"
                                                                          :dbname "test"
                                                                          :classname "com.facebook.presto.PrestoDriver"
                                                                          :port 8081
                                                                          :host ""
                                                                          :user "admin"}))]
            (println (jdbc/execute! sql-conn ["show catalogs;"])))
          (catch Exception ex
            (Throwable->map ex)))
;; {:cause "line 1:38: mismatched input ';'. Expecting: 'LIKE', <EOF>", :via [{:type java.sql.SQLException, :message "Query failed (#20190512_211107_00142_38vp7): line 1:38: mismatched input ';'. Expecting: 'LIKE', <EOF>", :at [com.facebook.presto.jdbc.PrestoResultSet resultsException "" 1840]} {:type com.facebook.presto.jdbc.internal.client.FailureInfo$FailureException, :message "line 1:38: mismatched input ';'. Expecting: 'LIKE', <EOF>", :at [com.facebook.presto.sql.parser.ErrorHandler syntaxError "" 92]}], :trace [[com.facebook.presto.sql.parser.ErrorHandler syntaxError "" 92] [org.antlr.v4.runtime.ProxyErrorListener syntaxError "" 41] [org.antlr.v4.runtime.Parser notifyErrorListeners "" 540] [org.antlr.v4.runtime.DefaultErrorStrategy reportUnwantedToken "" 351] [org.antlr.v4.runtime.DefaultErrorStrategy singleTokenDeletion "" 515] [org.antlr.v4.runtime.DefaultErrorStrategy sync "" 240] [com.facebook.presto.sql.parser.SqlBaseParser statement "" 2370] [com.facebook.presto.sql.parser.SqlBaseParser statement "" 2681] [com.facebook.presto.sql.parser.SqlBaseParser singleStatement "" 235] [com.facebook.presto.sql.parser.SqlParser invokeParser "" 140] [com.facebook.presto.sql.parser.SqlParser createStatement "" 93] [com.facebook.presto.execution.SqlQueryManager getQueryType "" 517] [com.facebook.presto.execution.SqlQueryManager createQueryInternal "" 419] [com.facebook.presto.execution.SqlQueryManager lambda$createQuery$3 "" 377] [java.util.concurrent.Executors$RunnableAdapter call "" 511] [java.util.concurrent.FutureTask run "" 266] [java.util.concurrent.ThreadPoolExecutor runWorker "" 1149] [java.util.concurrent.ThreadPoolExecutor$Worker run "" 624] [java.lang.Thread run "" 748]]}


(unreadable here - adding to the gist)


happy to use Throwable->map for the time being, it provides enough information


has anyone worked with a server-side jdbc library? as in, I have a custom app that want to look like a SQL database. (like Sybase OpenServer, for the other 6 people in the world who have used it.) So far, searching on “sql server jdbc” is… unhelpful.


No, but sounds a bit like KSQL, as in that's also a java application that accepts a SQL-like syntax.


I think that’s a much bigger architectural commitment. 🙂


Sounds like you'd want to implement the JDBC spec, or at least a subset of it, and that's a massive undertaking. Can you explain a bit about why you want to do this?


The easy summary is I have a custom datastore — more or less Datomic with a bunch of logic on top of it — and I need to make it accessible to JDBC tools. (via various projections into “tables”, of course).


That was the beauty of Sybase OpenServer — it handled all the client/server spec and you just had to interpret and feed it back a set of rows.


With a little bit of digging this afternoon, it looks like Apache Calcite may be the right tool to get me started, though I haven’t seen anyone try it from Clojure.


Oh, that does sound interesting! If you go down that path, please keep us posted here, and let me know if anything in or next.jdbc blocks you from working with that.

👍 1
hiredman17:05:22 is a thing I wrote a long time ago to use jdbc to query agilezen's (a ticket tracker) rest api


the really annoying bit is to be a jdbc driver you have to parse sql