I'm using Play Framework, and the following error occurred after adding models to the application:

java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: PLAY_EVOLUTIONS
 org.hsqldb.jdbc.Util.sqlException(Unknown Source)

My config:

db.queen.driver=org.hsqldb.jdbcDriver
db.queen.url="jdbc:hsqldb:file:queen-db;shutdown=true;hsqldb.write_delay=false;"
db.queen.user=sa
db.queen.password=""

ebean.queen="models.*"

I have only one evolution with one table (Users), and I also have one model (User). What's wrong with my application?

ADD I've discovered that my table Users not created after I've introduced User model

My evolution (1.sql):

# Users schema

# --- !Ups

CREATE TABLE User (
    id bigint(20) NOT NULL AUTO_INCREMENT,
    first_name varchar(255) NOT NULL,
    last_name varchar(255) NOT NULL,
    nick_name varchar(255) NOT NULL,
    PRIMARY KEY (id)
);

# --- !Downs

DROP TABLE User;

ADD I've created new applciation without models and got following error

[info] play - database [default] connected at jdbc:hsqldb:file:queen-db;shutdown=true;hsqldb.write_delay=false;
[warn] application - play_evolutions table already existed
[error] application -

! @6emindcmh - Internal server error, for (GET) [/users] ->

play.api.UnexpectedException: Unexpected exception[SQLSyntaxErrorException: user lacks privilege or object not found: PLAY_EVOLUTIONS]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$1.apply(ApplicationProvider.scala:142) ~[play_2.10.jar:2.1.1]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$1.apply(ApplicationProvider.scala:106) ~[play_2.10.jar:2.1.1]
at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
at play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:106) ~[play_2.10.jar:2.1.1]
at play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:104) ~[play_2.10.jar:2.1.1]
at scala.util.Either$RightProjection.flatMap(Either.scala:523) [scala-library.jar:na]
Caused by: java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: PLAY_EVOLUTIONS
at org.hsqldb.jdbc.Util.sqlException(Unknown Source) ~[hsqldb-2.2.9.jar:2.2.9]
at org.hsqldb.jdbc.Util.sqlException(Unknown Source) ~[hsqldb-2.2.9.jar:2.2.9]
at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source) ~[hsqldb-2.2.9.jar:2.2.9]
at org.hsqldb.jdbc.JDBCStatement.executeQuery(Unknown Source) ~[hsqldb-2.2.9.jar:2.2.9]
at com.jolbox.bonecp.StatementHandle.executeQuery(StatementHandle.java:503) ~[bonecp.jar:0.7.1.RELEASE]
at play.api.db.evolutions.Evolutions$.executeQuery(Evolutions.scala:118) ~[play-jdbc_2.10.jar:2.1.1]
Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: PLAY_EVOLUTIONS
at org.hsqldb.error.Error.error(Unknown Source) ~[hsqldb-2.2.9.jar:2.2.9]
at org.hsqldb.error.Error.error(Unknown Source) ~[hsqldb-2.2.9.jar:2.2.9]
at org.hsqldb.SchemaManager.getTable(Unknown Source) ~[hsqldb-2.2.9.jar:2.2.9]
at org.hsqldb.ParserDQL.readTableName(Unknown Source) ~[hsqldb-2.2.9.jar:2.2.9]
at org.hsqldb.ParserDQL.readTableOrSubquery(Unknown Source) ~[hsqldb-2.2.9.jar:2.2.9]
at org.hsqldb.ParserDQL.XreadTableReference(Unknown Source) ~[hsqldb-2.2.9.jar:2.2.9]

My application' config:

application.langs="en"

db.default.driver=org.hsqldb.jdbcDriver
db.default.url="jdbc:hsqldb:file:queen-db;shutdown=true;hsqldb.write_delay=false;"
db.default.user=sa
db.default.password=""

ebean.default="models.*"

PS: I've shared my sources: https://github.com/skayred/play-hsqldb-test

有帮助吗?

解决方案

User is a reserved keyword in HSQLDB. You could user "User"instead but i'd recommend you to rename the table to something else, and provide the name of the table in the Table annotation like follows:

@Entity
@Table(name = "my_user_table")
public class User { .... }

EDIT ON UPDATE:

The error you get happens when trying to apply Evolutions. As Evolutions come from the SQL file, even if you don't have model they are run if the SQL exists (Evolutions and model classes are related in purpose but Play considers each one an independent component)

The error means that either the database can't be accessed or your user has no privileges. I see you are trying to use the same database as before. I'd do the following:

  • Create a new project, from scratch, with no files besides the one play new generates.
  • Create a new database. Don't reuse the previous one,.
  • Add your new database details to that new project
  • Try to launch the application. It may fail here, then you know your db details are wrong.
  • If it works, add the Evolution files to your new project
  • Try to run the project again. If it fails, you will know it is the Evolution file that is wrong (syntax errors)
  • Add the model classes
  • Try to run the project again. If it fails, you know your model doesn't match the database.

Doing the steps in order should help you locate the error.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top