slick-3.0

call simple database procedure using Slick 3.0

ε祈祈猫儿з 提交于 2020-01-05 10:35:04
问题 I have written a simple database procedure in mySQL as follows: DROP PROCEDURE IF EXISTS sp_doSomething; DELIMITER // CREATE PROCEDURE sp_doSomething (IN pVal1 varchar(100), IN pVal2 int(15) ) BEGIN DECLARE vCnt int(5) DEFAULT 0; DECLARE vID int(15) DEFAULT 0; DECLARE vTempID int(15) DEFAULT 0; -- get ID SELECT id INTO vID FROM T1 WHERE name = pVal1; -- get count SELECT count(*) INTO vCnt FROM T1 WHERE owner = vID; -- get the log INSERT INTO log select CONCAT('-v1-:', pVal1, ':-v2-:', pVal2);

Caused by: java.sql.SQLException: JDBC4 Connection.isValid() method not supported

烂漫一生 提交于 2020-01-03 13:06:48
问题 My play-framework project is running well in my local but when I am trying to deploy it in heroku I am getting following error. 2015-07-05T06:24:10.456657+00:00 app[web.1]: at com.google.inject.Guice.createInjector(Guice.java:73) 2015-07-05T06:24:10.456817+00:00 app[web.1]: at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:93) 2015-07-05T06:24:10.456702+00:00 app[web.1]: at com.google.inject.Guice.createInjector(Guice.java:62) 2015-07-05T06:24:10.456746+00

How to configure Slick 3.1.1 for PostgreSQL? It seems to ignore my config parameters while running plain sql queries

ε祈祈猫儿з 提交于 2019-12-24 07:21:35
问题 I have two days trying to run a plain SQL query using Slick 3.1.1, I followed the Getting Started and Database Configuration guides. The issue is that while the code compiles properly, it is ignoring my database parameters (the ones in the config are wrong), it prints this to StdOut (while it should throw an exception): HikariCP pool database is starting. List() Here is my test code: import slick.driver.PostgresDriver.api._ import scala.concurrent.ExecutionContext.Implicits.global object app

How to configure Slick 3.1.1 for PostgreSQL? It seems to ignore my config parameters while running plain sql queries

雨燕双飞 提交于 2019-12-24 07:20:44
问题 I have two days trying to run a plain SQL query using Slick 3.1.1, I followed the Getting Started and Database Configuration guides. The issue is that while the code compiles properly, it is ignoring my database parameters (the ones in the config are wrong), it prints this to StdOut (while it should throw an exception): HikariCP pool database is starting. List() Here is my test code: import slick.driver.PostgresDriver.api._ import scala.concurrent.ExecutionContext.Implicits.global object app

Assign dynamically injected database name in Play Slick

◇◆丶佛笑我妖孽 提交于 2019-12-24 05:35:08
问题 I have the following Play Slick DAO class. Note that the database configuration is a constant control0001 . The DAO has a function readUser that reads a user based on its user id: class UsersDAO @Inject()(@NamedDatabase("control0001") protected val dbConfigProvider: DatabaseConfigProvider) extends HasDatabaseConfigProvider[JdbcProfile] { import driver.api._ def readUser (userid: String) = { val users = TableQuery[UserDB] val action = users.filter(_.userid === userid).result val future = db

Scala - Slick - Getting a TypedType for a wrapped Option[T]

别说谁变了你拦得住时间么 提交于 2019-12-24 03:55:11
问题 It is usual to create custom IDs like this: case class CustomID(value: Int) extends MappedTo[Int] and to represent nullable custom IDs with types like Option[CustomID]. However, I would like to be able to move Option[_] into the case class, like this: case class OptCustomID(optValue: Option[Int]) To be more specific, I am looking for a TypedType[OptCustomId] that behaves like the built-in TypedType[Option[Int]] for what concerns the database DDL. Any ideas? 回答1: Actually you don't need

How to update a row omitting a column in Slick 3.x?

岁酱吖の 提交于 2019-12-24 00:35:34
问题 I have the following code in Slick that updates an object user: val users = TableQuery[UserDB] val action = users.filter(_.id === user.id).update(user) val future = db.run(action) val result = Await.result(future, Duration.Inf) But there's a field in the user object (password) that I don't want to update. How to omit it? 回答1: You should select columns using a map operation before an update operation: case class User(name: String, age: Int, password: String, id: Int) val updatedUser = User(

Slick 3.1 - Retrieving subset of columns as a case class

独自空忆成欢 提交于 2019-12-20 10:28:07
问题 I'm working with Slick 3.1.1 and the problem is that in some cases I want to omit some columns that are fairly heavy and still materialize that subset of columns as a case class. Consider the following table definition: class AuditResultTable(tag: Tag) extends Table[AuditResult](tag, AuditResultTableName) { def auditResultId: Rep[Long] = column[Long]("AuditResultId", O.PrimaryKey, O.AutoInc) def processorId: Rep[Long] = column[Long]("ProcessorId") def dispatchedTimestamp: Rep[Timestamp] =

Executing non-database actions in a transaction in Slick 3

夙愿已清 提交于 2019-12-20 08:58:29
问题 I'm having trouble understanding the new Slick DBIOAction API, which does not seem to have a lot of examples in the docs. I am using Slick 3.0.0, and I need to execute some DB actions and also some calculations with the data received from the database, but all of those actions have to be done inside a single transaction. I'm trying to do the following: Execute a query to database (the types table). Do some aggregations and filtering of the query results (this calculation can't be done on the

Can't connect to mysql database with play-slick 1.0.1/slick 3.0 : configuration error

自作多情 提交于 2019-12-20 05:35:15
问题 I'm trying to migrate from anorm to slick, using play 2.4.2, and getting a configuration error: play.api.Configuration$$anon$1: Configuration error[Cannot connect to database [dethcs]] at play.api.Configuration$.configError(Configuration.scala:178) ~[play_2.11-2.4.0.jar:2.4.0] ... Caused by: slick.SlickException: Error getting instance of Slick driver "slick.driver.MySQLDriver" ... Caused by: java.lang.NoSuchMethodException: slick.driver.MySQLDriver.<init>() Previous answers I've found on SO