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?
Maybe take a step back and explain the problem you are trying to solve here? It sounds like you’re trying to jump into some really low-level stuff that you almost certainly do not need to do. You asked “What is the correct way to do this?” but it’s not at all clear what you’re trying to do so I don’t know how to answer it, other than suggesting you read the docs and join the Slack community so you can have real time conversations where folks can better understand how to help you by asking you questions and looking at your code. The mailing list is just too slow a medium for the sort of conversations I think you need to have at this stage in your Clojure journey. Sean Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ "If you're not annoying somebody, you're not really alive." -- Margaret Atwood From: Laws Sent: Tuesday, October 22, 2019 3:17 PM To: Clojure Subject: Re: How can I do something like (= (class ds) next.jdbc.connection)?? > 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> 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 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 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. To view this discussion on the web visit https://groups.google.com/d/msgid/clojure/8a486bd5-bb5f-41ef-bcb6-74e49ed58db4%40googlegroups.com. -- 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. -- 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/5daf8949.1c69fb81.3259e.0353%40mx.google.com.