ScalikeJDBC is a tidy SQL-based DB access library for Scala developers. This library naturally wraps JDBC APIs and provides you easy-to-use and very flexible APIs.
Questions tagged [scalikejdbc]
97 questions
0
votes
1 answer
postgres: sql error while using string interpolation (scala + scalikejdbc)
Here is the query I execute on Postgres from scala using scalikejdbc library which works without any issue
import scalikejdbc._
import java.time.LocalDate
def getRange(startDate: LocalDate, endDate: LocalDate): Unit = {
implicit val session:…

Raj
- 2,368
- 6
- 34
- 52
0
votes
1 answer
Error when trying to retrieve json data from h2 database
I have the following table definition
create table samples (
channel text,
eventType text,
data json NOT NULL
);
I have also tried defining the data column as clob,text,java_object,varchar,other.
I am using the following API to insert data…

Niko
- 616
- 4
- 20
0
votes
1 answer
ScalikejdbcGen ClassNotFoundException on Reverse Engineering from Schema
I am following this documentation for ScalikeJDBCGen, which can generate source code from MySQL schema. However on executing below command I receive ClassNotFoundException.
I can see MySql in my sbt dependencies. Also I tried to run this by removing…

Pratik K. Shah
- 397
- 3
- 17
0
votes
1 answer
Scala JDBC project won't run outside of Docker Container?
com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: The connection attempt failed.
I get the above error when entering sbt run However, inside my docker containers everything works fine.
Inside the first…

Ry2254
- 859
- 1
- 10
- 19
0
votes
1 answer
Scalalikejdbc Implicit Parameter
Trying to understand the following syntax (the implicit session) in Scala:
def getDates(date: String): Option[String] = DB.readOnly { implicit session =>
val date = "20201020"
}
Using the readOnly method from scalalikejdbc. Definition of method…

kgui
- 4,015
- 5
- 41
- 53
0
votes
0 answers
How to prevent `scalike` from converting `LocalDateTime` to a specific LocalDateTime
I am using scalike as a simple sql connector.
To retrieve sql.timestamp to LocalDateTime we use wrappedResultSet.localDateTime(1).
Unfortunately, it does add an offset (+1 in my case).
By digging the scalike code, I have seen this is a…

BlueSheepToken
- 5,751
- 3
- 17
- 42
0
votes
1 answer
When use foreachPartition to write data in rdd into mysql , i lost mysql connection occasionally
i use spark rdd to write data into mysql, the operator i use is foreachPartition, in the operator i set up connection pool and write data(using scalike jdbc's), then destory the pool, howerver it seems the connection pool cannot be found…

Js_zero
- 63
- 7
0
votes
1 answer
ScalikeJDBC Configuration without HOCON
I need to initialize from ~/myConfig.json, which looks like:
{
"databaseActive": "production",
"databases": [
{
"name": "localhost",
"PGDB": "asdf",
"PGHOST": "localhost",
"PGPASSWORD": "asdf",
"PGPORT":…

Mike Slinn
- 7,705
- 5
- 51
- 85
0
votes
0 answers
No operations allowed after statement closed happens when inserting a batch of rows containing large column fields
I am currently migrating data from a database to another.
For this, I have written a Scala program that uses both Slick and ScalikeJDBC for fetching data from an old database and inserting into a new database respectively.
The problem I am facing…

d-_-b
- 4,142
- 6
- 28
- 43
0
votes
1 answer
Update returning queries in ScalikeJDBC
With an implicit val session: DBSession in scope, concretely as a scalikejdbc.AutoSession:
Updates work
sql"""
update payments set status=${status.name} where id in ($ids)
""".update().apply()
And selects work
sql"""
select id
from…

Synesso
- 37,610
- 35
- 136
- 207
0
votes
1 answer
Looking for help in Nested groupBy with scalikejdbc?
I am using Scala 2.12 and have required libraries downloaded via build.sbt.
I have my DB output in below format.
Basically, it is like per valuation date and book, there can be multiple currency data.
I have group by on book (majorly), which will…

Mihir
- 531
- 2
- 10
- 35
0
votes
1 answer
Applying evolutions to ScalikeJDBC in-memory test DB
I'm using ScalikeJDBC with Play. I want to apply evolutions to an in-memory database for my Specs2 tests.
import org.specs2.mutable.Specification
import org.specs2.specification.BeforeAfterAll
import play.api.db.{Database, Databases}
import…

Synesso
- 37,610
- 35
- 136
- 207
0
votes
0 answers
Functional way of implementing DB access with additional logic
Currently, my goal is to communicate with DB using CRUD approach. Between simple operation i may have some extra steps (additional business-logic which may throw some errors).
import cats.effect.IO
import scalikejdbc._
IO(NamedDB(MyDB) localTx {
…

Nikita Ryanov
- 1,520
- 3
- 17
- 34
0
votes
1 answer
Ignite - use variable in sql command?
I wanno read from cache memory using sql command. Since sql commands are dynamic each time, I need to input it as variable but using variable in sql command is not supported. Here is my code:
import com.typesafe.config.{Config, ConfigFactory}
import…

ArefehTam
- 367
- 1
- 6
- 20
0
votes
1 answer
How to save record in postgres with custom type using scalikejdbc?
In my case i have a enum type in postgres:
create type my_type as enum (string value);
And some tables, using this as column type:
create table A (
...
t my_type,
...
)
In postgres i can insert new record in table A like this:
insert into A…

Nikita Ryanov
- 1,520
- 3
- 17
- 34