DaveS
DaveS

Reputation: 3294

Play Framework: How do I change the sort order of my database?

I have a Play app with db=mem in my application.conf file, and I want to be able to set the database's collation to French, with strength set to primary. Any idea how to do this?

If I add

db.url=jdbc:h2:mem:play;

to my application.conf file, it runs, but using the wrong collation. If I change it to

db.url=jdbc:h2:mem:play;COLLATION=FRENCH;

as per instructions here: h2 Changing Other Settings when Opening a Connection. It breaks, giving the following error:

A database error occured : Cannot connected to the database, URL format error; must be "jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]" but is "jdbc:h2:mem:play" [90046-149]

So it looks like COLLATION isn't a supported parameter.

What is the proper way to set the db sort order in Play?

Upvotes: 4

Views: 539

Answers (2)

Thomas Mueller
Thomas Mueller

Reputation: 50127

The problem is the trailing semicolon (the one at the very end). This works:

jdbc:h2:mem:play;COLLATION=FRENCH

this doesnt:

jdbc:h2:mem:play;COLLATION=FRENCH;

Upvotes: 1

DaveS
DaveS

Reputation: 3294

Sorry to answer my own question, but I got it working thanks to this question: Can I have H2 autocreate a schema in an in-memory database?.

The line that works for me is

db.url=jdbc:h2:mem:play;INIT=SET COLLATION FRENCH STRENGTH PRIMARY

Upvotes: 3

Related Questions