scalikejdbc

Calling a string interpolator on a variable in Scala

拜拜、爱过 提交于 2019-12-14 03:14:20
问题 I am writing some database query helper methods for my classes in Scala. This select method is intended to pluck certain columns from the Product table, specified as a comma-seperated list (String) of the desired columns. I want to be able to call it like this: Product.select("id, title") The following code does not work: def select(columns: String) = { DB.readOnly{ implicit session => sql"select ${columns} from $sqlTable limit 1000".map(row => Product(row)).list.apply() }} But this code (for

Release a Connection borrowed from ConnectionPool

佐手、 提交于 2019-12-11 16:09:14
问题 ScalikeJDBC's ConnectionPool docs page says: Borrowing Connections Simply just call #borrow method. import scalikejdbc._ val conn: java.sql.Connection = ConnectionPool.borrow() val conn: java.sql.Connection = ConnectionPool('named).borrow() Be careful. The connection object should be released by yourself. However there's no mention of how to do it. I can always do Connection.close() but by ' releasing ' Connection , I understand that I'm supposed to return the Connection back to the

ScalikeJDBC: Connection pool is not yet initialized.(name:'default)

北慕城南 提交于 2019-12-10 04:57:14
问题 I'm playing with ScalikeJdbc library. I want to retrieve the data from PostgreSQL database. The error I get is quite strange for me. Even if I configure manually the CP: val poolSettings = new ConnectionPoolSettings(initialSize = 100, maxSize = 100) ConnectionPool.singleton("jdbc:postgresql://localhost:5432/test", "user", "pass", poolSettings) I still see the error. Here is my DAO: class CustomerDAO { case class Customer(id: Long, firstname: String, lastname: String) object Customer extends

troubleshooting jar loading conflicts in sbt

家住魔仙堡 提交于 2019-12-08 16:35:21
问题 I get the following error on sbt startup, when two specific sbt plugins are added together to a project in its build definition. One of these sbt plugins is scalikejdbc and the other is my own, and clearly their mutual inclusion in a project's build definition results in this error upon sbt startup: scala.reflect.internal.Types$TypeError: package macros contains object and package with same name: blackbox Clearly, it looks as if each plugin brings along a different version of scala.reflect