simonC simonC - 9 months ago 34
Scala Question

jooq postgre insert error with play2.5 scala

I'm using jooq in an app with play2.5 and scala

when i'm inserting a simple querry the driver prepares a query with ` around table and field names and postgre responds with an error, how can I overcome this, there is probably a driver parameter to set this behavior?

I'm using

the sbt config

libraryDependencies ++= Seq(
jdbc,
cache,
ws,
evolutions,
filters,
"org.scalatestplus.play" %% "scalatestplus-play" % "1.5.0-RC1" % Test,
"org.postgresql" % "postgresql" % "9.2-1003-jdbc4",
"org.jooq" % "jooq" % "3.7.0",
"org.jooq" % "jooq-codegen-maven" % "3.7.0",
"org.jooq" % "jooq-meta" % "3.7.0",
"joda-time" % "joda-time" % "2.7",
"com.adrianhurt" %% "play-bootstrap" % "1.1-P25-B3",
"org.mindrot" % "jbcrypt" % "0.3m"
)


the error:

[debug] 2017-03-12 11:18:52,042 o.j.t.LoggerListener - Executing query : insert into `public`.`user_account` (`nickname`, `email`, `password`, `role`) values (?, ?, ?, ?)
[debug] 2017-03-12 11:18:52,043 o.j.t.LoggerListener - -> with bind values : insert into `public`.`user_account` (`nickname`, `email`, `password`, `role`) values ('', 'simon.cigoj@gmail.com', 'nomis05', 'ROLE_USER')
[error] 2017-03-12 11:18:52,139 o.j.StatementLogger - insert into `public`.`user_account` (`nickname`, `email`, `password`, `role`) values ('', 'aaa@mail.com', 'kjhkh', 'ROLE_USER');
throws exception: org.postgresql.util.PSQLException: ERROR: syntax error at or near "`"
Position: 13
org.postgresql.util.PSQLException: ERROR: syntax error at or near "`"
Position: 13

Answer Source

It looks like you did not set the correct SQLDialect, like

SQLDialect.POSTGRES_9_5

https://www.jooq.org/javadoc/3.8.x/org/jooq/SQLDialect.html