Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting sqlite to run on play 2.5

How do i get sqlite to run on play 2.5, exactly?

The documentation is good, but it skips too much - verbosity is better than brevity!

(I mean, if you know how - please answer! But this is just a holding question for when i do find an answer)

like image 753
bharal Avatar asked Dec 18 '25 13:12

bharal


1 Answers

Whoooooie! Get out your ouji boards and your lucky charms and let's get staaarted!

  1. there are two files you will be editing here - they are build.sbt and application.conf NOTE - You don't need to download the driver, play does that

  2. Oh whoaie, let's look at build.sbt

    • First up this is the file that tells play that we need some sort of driver
    • Look for libraryDependencies in yours (or add it in if missing, i guess)

    • libraryDependencies ++= Seq( javaJdbc, cache, javaWs, "org.xerial" % "sqlite-jdbc" % "3.8.6" )

    • that last line is the one you MUST have, The other lines were added by activator. Now, that last line is because I am using sqlite driver 3.8.6, by far the best driver I have found - BUT you might want other versions? They are found here, just change the version to get them. NOTE - we are changing the repository to get them, so make sure it has it (more on this... NOW!)
    • Next:
    • fork in run := false resolvers += "SQLite-JDBC Repository" at "https://oss.sonatype.org/content/repositories/snapshots"
    • the first line is because on Windows 10, play is busted custard with the "fork" stuff, so we just set it to false. Maybe on your os you do not have that issue? You can have that one for free.
    • the next line is to add a repository to get our sqlite db from - and that is a repository that has it! You can open the repository contents here
    • make sure that the repository contents match the flavour you picked in the first link, if not - um, find a new repository? IDK, i'd just use 3.8.6 if i were you
  3. Cool, you are nearly there great job!

    • In the section play.db
    • play.db { config = "db" default = "default"
    • they were commented before, but that is sometimes problematic (at least, it was for me). Once I had this all working, commenting/uncommenting them had no apparent effect, I'm not sure if you need to uncomment them - but i did.
    • Immediately under it, in the section db
    • db { default.driver=org.sqlite.JDBC default.url="jdbc:sqlite:c:\\development\\other\\words\\theFileName.sqlite" }
    • NOTICE that we removed the leading "db" that other, lesser tutorials might tell you to add (so don't have db.default.url=...)
    • NOTICE that it is url, not jdbcUrl, which sometimes an error message asks for
    • also notice that the file path is absolute to your file (but it doesn't need to be! \\words\\theFileName.sqlite would work if the words director were directly under your project directory ~ in this case then, your project would be in the other directory)
    • also note that you use double slash (\\) for windows, i don't linux but it is probably /
  4. FINALLY make sure you restart your activator or your sbt or what have you, don't trust play's plug-and-fix code for this stuff.

like image 71
bharal Avatar answered Dec 21 '25 05:12

bharal