Connect "computer-database-jpa" Play example 2.1 application with MySQL

I play with computer-database-jpa (Java) Sample application Framework Framework 2.1. Everything works fine when I use H2 in the memory database, but I had problems when I want to connect the application to MySQL.

Someone had the same problem ( Did you get an example of an application connected to MySQL ), but there was no solution.

I added mysql-connector(Build.scala):

val appDependencies = Seq(
  ....
  "mysql" % "mysql-connector-java" % "5.1.18"
)

and edited application.conf:

db.default.url="jdbc:mysql://password:user@localhost/my-database"
db.default.driver=com.mysql.jdbc.Driver

When I launch applications and apply 1.sql (evolution script), I get an error message:

You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'sequence company_seq
start with 1000' at line 1 [ERROR:1064, SQLSTATE:42000]

Does anyone have an idea how to solve the problem?

+5
source share
1

- https://github.com/opensas/openshift-play2-computerdb.

, , MySQL:

, H2 mysql

Conf// /1.sql

  • = innodb,
  • id
  • "SET REFERENTIAL_INTEGRITY" "SET FOREIGN_KEY_CHECKS"
  • timestamp datetime

Conf// /2.sql

  • 2.sql 3.sql( , mysql)

/Models.scala

  • "nulls last" SQL- Computer.list
  • Computer.insert, id ( mysql)

Java, Scala, Company.java Computer.java. @GeneratedValue:

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
public Long id;

: https://github.com/opensas/openshift-play2-computerdb/tree/master/conf/evolutions/default

+8

All Articles