> The ds binding that you have will satisfy this check (instance? javax.sql.DataSource ds) -- > because it is an instance of that Java interface.
My experience so far has been a lot of this stuff seems like commonsense to those programmers who have a background with Java, but those of us who learn Clojure without knowing Java have a harder time picking this up. Part of my question was "How do I know this?" Or in your case, how did you know this? The reason I included the link to the Github page is I was hoping to find out what on that page I was supposed to look at to figure out the answer. With the clue you gave me, I can look at that page and I see that javax.sql.DataSource is used in two protocols, so I guess I could then look to see where those protocols are used. But I'm thinking there might be an easier way to reverse-engineer an interface or class to get something that I can use in an if statement, when I'm adding in a runtime check? I'm a little surprised that (class) and (type) and (ancestors) did not give me something that I could use. On Friday, October 18, 2019 at 12:23:02 AM UTC-4, Sean Corfield wrote: > > You should :require the namespaces, not try to :import things. > > (ns your.namespace > (:require [next.jdbc :as jdbc])) > > I suggest you start off by working through > https://cljdoc.org/d/seancorfield/next.jdbc/1.0.9/doc/getting-started > > The ds binding that you have will satisfy this check (instance? > javax.sql.DataSource ds) -- because it is an instance of that Java > interface. > > It sounds like you have quite a few misconceptions about using the library > (and perhaps using Clojure in general?) so I highly recommend joining the > Clojurians Slack http://clojurians.net and https://clojurians.slack.com > where you can ask real time questions in the #beginners channel and > next.jdbc-specific questions in the #sql channel. > > > > On Thu, Oct 17, 2019 at 6:03 PM Laws <smashco...@gmail.com <javascript:>> > wrote: > >> If I do this: >> >> (class ds) >> >> I see: >> >> next.jdbc.connection$url_PLUS_etc$reify__555 >> >> Is there anyway I can match against this? I'd like a runtime check to >> know that the code really does have a database connection. Imagine code >> like this: >> >> (if (= next.jdbc.connection (class ds)) >> (println "its next.jdbc.connection") >> (println "fail, it is not next.jdbc.connection")) >> >> I get errors such as: >> >> java.lang.ClassNotFoundException: seancorfield/next.jdbc.Connection, >> compiling:(core.clj:1:1) >> >> The namespace is here: >> >> >> https://github.com/seancorfield/next-jdbc/blob/master/src/next/jdbc/connection.clj >> >> >> (:import >> [seancorfield/next.jdbc Connection] >> ) >> >> (:import >> [next.jdbc Connection] >> ) >> >> (:import >> [next.jdbc.connection] >> ) >> >> >> What is the correct way to do this? >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clo...@googlegroups.com >> <javascript:> >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clo...@googlegroups.com <javascript:> >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en >> --- >> You received this message because you are subscribed to the Google Groups >> "Clojure" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to clo...@googlegroups.com <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/clojure/8a486bd5-bb5f-41ef-bcb6-74e49ed58db4%40googlegroups.com >> >> <https://groups.google.com/d/msgid/clojure/8a486bd5-bb5f-41ef-bcb6-74e49ed58db4%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > > > -- > Sean A Corfield -- (904) 302-SEAN > An Architect's View -- http://corfield.org/ > World Singles Networks, LLC. -- https://worldsinglesnetworks.com/ > > "Perfection is the enemy of the good." > -- Gustave Flaubert, French realist novelist (1821-1880) > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/clojure/bb43da65-d4be-4afa-bd86-5707817a5764%40googlegroups.com.