Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Hands on the sqlite3-jdbc library in Scala

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

%classpath add mvn org.xerial sqlite-jdbc 3.27.2.1
Loading...
Loading...
import collection.JavaConverters._
scala.collection.JavaConverters$@355c65bd
import java.sql.DriverManager

val connection = DriverManager.getConnection("jdbc:sqlite:sample.db")
org.sqlite.jdbc4.JDBC4Connection@7fababf3
val statement = connection.createStatement()
org.sqlite.jdbc4.JDBC4Statement@38fe3ed7
statement.setQueryTimeout(30)
statement.executeUpdate("drop table if exists person")
0
statement.executeUpdate("create table person (id integer, name string)")
0
statement.executeUpdate("insert into person values(1, 'leo')")
1
statement.executeUpdate("insert into person values(2, 'yui')")
1
val results = statement.executeQuery("select * from person")
org.sqlite.jdbc4.JDBC4ResultSet@5ecf21c
while(results.next()){
    println("name = " + results.getString("name"))
    println("id = " + results.getInt("id"))
}
println(1)