slick

slick & sqlite : Could not instantiate class tests.SqliteSpec: org.sqlite.JDBC

試著忘記壹切 提交于 2019-12-11 19:52:29
问题 I try to begin an app with scala, play, slick, specs2 & sqlite.here is a trait for sqlite integration: import scala.slick.driver.SQLiteDriver.simple._ import metier.Objets._ import scala.slick.lifted.ProvenShape import java.sql.Date package models { trait sqlite { val db = Database.forURL("jdbc:sqlite:rdvs.txt", driver = "org.sqlite.JDBC") //val db = Database.forDataSource(DB.getDataSource()) class Personnes(tag: Tag) extends Table[Rdv](tag, "RDV") { def id = column[Int]("ID", O.PrimaryKey, O

Slick table Query: Trouble with recognizing values

落花浮王杯 提交于 2019-12-11 19:33:47
问题 Can anyone tell me why in this case: Query(Users) foreach {case (userId, userName) => println(userId + ", " + userName) } Scala recognizes userId, but in this case: val l = List[(Int, String)]() Query(Users) foreach { case (userId, userName) => l::(foo(List[(userId, userName)])) } it doesnt? (as in, the userId on the right of the "=>" is recognized in the second case but not the first) Users is a slick-mounted database that looks like this: object Users extends Table[(Int, String)]("Users") {

Slick 3.0 (scala) queries don't return data till they are run multiple times (I think)

こ雲淡風輕ζ 提交于 2019-12-11 19:29:36
问题 So I'm very (extremely) new to Databases and slick and scala, so I was using the example code from their documentation at http://slick.typesafe.com/doc/3.0.0/gettingstarted.html My problem is that for some reason, I have to run a query multiple times before it returns data. I have to rerun it atleast 3-4 times before it returns results. I use a for-loop to rerun the query and they don't necessarily give me the exact same results each time either. to create two tables as followed: class

How to select multiple column from database using scala Play2.6 and with proper json response header

别说谁变了你拦得住时间么 提交于 2019-12-11 18:56:01
问题 I have one table User details Table and it contains below Columns User_ID,Name,email,Mobile_no,firstname,lastname,Address I want to select these 4 columns(User_ID,Name,email,Mobile_no) data whose user id is 1 and i want the response as in proper JSON Format How to do that In Scala Play 2.6 with Slick Till now I have done this import play.api.mvc._ //import slick.driver.H2Driver.api._ import slick.jdbc.H2Profile.api._ import Services.HorseImageServices import scala.concurrent.{Await, Future}

Setting connectionPool crashes Slick 3.0

假如想象 提交于 2019-12-11 13:41:27
问题 I'm using Slick 3.0 with MySql and I'm getting terrible performance, which I want to tune. I initialize the database with val db = Database.forConfig("horridDBStuff") Then in application.conf I have horridDBStuff = { url = "jdbc:mysql://my.db.address:3306/myschema" driver = "com.mysql.jdbc.Driver" connectionPool = disabled keepAliveConnection = true properties = { user = "me" password = "me" } } Slick documentation says that in deployment you should enable the connection pool, so that's what

Can I build update query with variable fields without using plain SQL?

邮差的信 提交于 2019-12-11 13:17:33
问题 Can I build update query with variable number of fields without using plain SQL ? For example update of single column is simple - I just yield it to create narrow query. Query(RolesTable).filter((role: RolesTable.type) => role.id === role_id).map((role: RolesTable.type) => role.name).update(name) But what if Role has 5 fields and I want to allow API client to send me fields he wants to update ? How would I construct such query ? 回答1: The key here is to use the ~ operator when yielding the

Where can I define methods to be called on Tables?

大兔子大兔子 提交于 2019-12-11 12:39:33
问题 (I'm a complete beginner with Scala and Slick, so code review of any kind is appreciated) I have the following class and Slick Table defined: case class Foo(title: String, description: String, id: Int = 0) class FooTable(tag: Tag) extends Table[Foo](tag, "FOO") { def id = column[Int]("ID", O.PrimaryKey, O.AutoInc) def title = column[String]("TITLE", O.NotNull) def description = column[String]("DESCRIPTION") def * = (title, description, id) <> (Foo.tupled, Foo.unapply) } I want to add a method

Set IGNORECASE and other options for H2 in a Play! Framework test

主宰稳场 提交于 2019-12-11 12:38:27
问题 I've setup my Play! (with Slick) application to use H2 when running tests, and it has worked great so far. I'm getting an error now, because of a plain-SQL query that uses lower-case column and table names, and H2 complains that the TABLE (all uppercase) could not be found. Now I need to set a few options, IGNORECASE for sure, and possibly the MODE . When I setup my database for tests, I use def fakeAppWithMemoryDatabase = FakeApplication(additionalConfiguration = inMemoryDatabase()) For

Can't draw a Buffered Image

霸气de小男生 提交于 2019-12-11 11:46:24
问题 I'm using this code to try and draw an image : g.drawImage(Tile.background, (int)spritePositionX, (int)spritePositionY, null); Here is the my tile class for Tile.background : public class Tile { public static int size = 40; public static BufferedImage terrain, background, items, characters; public Tile(){ try{ Tile.background = ImageIO.read(new File("res/bg.png")); Tile.terrain = ImageIO.read(new File("res/terrain.png")); Tile.items = ImageIO.read(new File("res/items.png")); Tile.characters =

how we use slick transaction on service layer for making a transaction System

喜你入骨 提交于 2019-12-11 11:36:43
问题 in my service layer i want to insert transaction-ally if insert than all the three row are inserted in database !! Service Layer is def service(userRow, addressDao, contactDao) = DB.withTransaction { implicit session => userDao.insert(userRow) addressDao.insert(addressRow) contactDao.insert(contactRow) } my dao layer is def insert(userRow: UsersRow) = DB.withTransaction { implicit session => user += userRow } 回答1: change your insert method to def insert(userRow:UsersRow)(implicit session: