A commonly experienced error when using CLSQL in a web environment is database connections conflicting with each other from simultaneous web requests. These problems arise because, by default, clsql standard-db-objects keep a reference to the connection they were queried / created from and reuse this database connection (rather than a new one you may have provided with clsql-sys:with-database). This means that two separate threads could try to use the same database connection (provided through clsql-sys:with-database or by having objects queried from the same connection accessed in multiple threads / http requests).
We solved this problem by introducing a clsql-sys::choose-database-for-instance method (available in clsql master branch from http://git.b9.com/clsql.git. (This branch will eventually be released as CLSQL6) Then in our web applications we define the following class and method override. Usually I then pass this name to clsql-orm or as a direct superclass to any of my web def-view-classes. After this, I just use with-database to establish dynamic connection bindings and everything pretty much works out (as these dynamic bindings are not shared across threads).
(defclass clsql::web-db-obj (clsql-sys:standard-db-object) nil (:metaclass clsql-sys::standard-db-class)) (defmethod clsql-sys::choose-database-for-instance ((object clsql::web-db-obj) &optional database) (or database clsql-sys:*default-database*)) (clsql-sys:def-view-class table-1 (clsql::web-db-obj) (...)) (clsql-orm:gen-view-classes :package :net.company.my.db :nicknames :my-db :export-symbols t :classes '(users employees salaries) :inherits-from '(clsql::web-db-obj))
Note: CLSQL-Fluid seems to be trying to accomplish much the same goals.