Re: *db* binding with jetty

2013-09-23 Thread Christopher Allen
Most web apps will either have a top-level def'd var that points to the database or they'll use a middleware to chain it into the request map. Which you do depends on your DB library. On Monday, September 23, 2013 1:23:50 PM UTC-7, Brian Craft wrote: > > My question is more about how to pass som

Re: *db* binding with jetty

2013-09-23 Thread Brian Craft
My question is more about how to pass something to the app without sticking it in a global. This might be a noir question. Handlers are called without any passed context. I'm not sure if that's peculiar to noir, or something inherited from ring. So, the only way I know to get context to the app

Re: *db* binding with jetty

2013-09-23 Thread Sean Corfield
Take a look at http://clojure-doc.org/articles/ecosystem/java_jdbc/connection_pooling.html You would want to set up a connection pool and pass that into your app as part of its context. Does that help? Sean On Mon, Sep 23, 2013 at 11:25 AM, Brian Craft wrote: > Trying to get a small app off t

Re: *db* binding with jetty

2013-09-23 Thread Brian Craft
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

Re: *db* binding with jetty

2013-09-23 Thread Andy Fingerhut
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 experien

*db* binding with jetty

2013-09-23 Thread Brian Craft
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 star