Skip to content

Instantly share code, notes, and snippets.

@jdkula
Last active February 16, 2018 08:33
Show Gist options
  • Select an option

  • Save jdkula/648bd1c29d3b74797ce1fbd065781643 to your computer and use it in GitHub Desktop.

Select an option

Save jdkula/648bd1c29d3b74797ce1fbd065781643 to your computer and use it in GitHub Desktop.
import org.jetbrains.exposed.sql.Table
object Games: Table() {
val id = text("id").primaryKey().uniqueIndex()
val location = text("location")
val spy_player = integer("spy_player")
val first_player = integer("first_player")
val time_start = integer("time_started")
val pause_time = integer("pause_time").nullable()
}
object Players: Table() {
val id = integer("id").primaryKey().uniqueIndex().autoIncrement()
val last_game = text("last_game").nullable()
val expires_at = integer("expires_at")
val name = text("name")
}
/* imports... */
def main(args: Array<String>) {
Database.connect("jdbc:sqlite:test.sqlite3", "org.sqlite.JDBC")
var userId: Int = -1
transaction(Connection.TRANSACTION_SERIALIZABLE, 2) { // <-- The failure below causes an AbstractMethodError here: Method org/sqlite/PrepStmt.isClosed()Z is abstract
create(Games, Players) // <-- Fails here; no ResultSet returned, SQLException
userId = Players.insert {
it[name] = "test"
it[expires_at] = 10
} get Players.id
}
println(userId)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment