Even in that case you have to get the db info to the handlers somehow. A lot of demo code I see just hard-codes the db stuff, which is not useful.
I can make it work via middleware, like (partial db db-middleware) then add db-middleware to ring before starting jetty. I'm not sure if this is a good plan, or how the db stuff will handle multiple threads. On Monday, September 23, 2013 11:42:59 AM UTC-7, Andy Fingerhut wrote: > > Caveat: I am experienced with Clojure, but a newbie at web development in > *any* language. I have recently begun going through the beta version of > the book "Web Development with Clojure" > > http://pragprog.com/book/dswdcloj/web-development-with-clojure > > Hopefully others with more web dev experience will respond with more > experience and knowledge to back up their answers. > > In the simple web server code I've been working with in the book, it does > not make a connection to the database when jetty is started. Instead, a > new connection is made to the database every time a request is handled, and > the connection is closed before the response is sent back. All of the > examples I have seen so far handle all requests within a single thread, so > it does not hit the issue you have run into. > > There are probably fancier techniques used when people are trying to > squeeze more performance out of their database interaction. > > Andy > > > On Mon, Sep 23, 2013 at 11:25 AM, Brian Craft <[email protected]<javascript:> > > wrote: > >> Trying to get a small app off the ground with noir/jdbc/jetty (jdbc >> 0.2.2, I think), I'm getting a "No valid DB connection selected" error. >> >> I suspect this is because I start it something like >> >> (with-connection mydb >> (server/start)) >> >> which creates a thread-local binding of *db* in jdbc, then starts jetty >> in a different thread, with no binding for *db*. >> >> Does that sound correct? >> >> If so, I'm not sure how to work around it. >> >> -- >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to [email protected]<javascript:> >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> [email protected] <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 [email protected] <javascript:>. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] 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 [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
