Own-Programming-Language-Tu.../examples/database/hsqldb.own

18 lines
721 B
Plaintext
Raw Normal View History

2019-01-13 21:52:26 +02:00
use ["std", "jdbc"]
connection = getConnection("jdbc:hsqldb:file:hsql.db", "", "", "org.hsqldb.jdbcDriver")
statement = connection.createStatement()
statement.executeUpdate("drop table if exists cities")
statement.executeUpdate("CREATE TABLE cities (id IDENTITY, name VARCHAR(32))")
statement.executeUpdate("INSERT INTO cities (name) VALUES('Киев')")
statement.executeUpdate("INSERT INTO cities (name) VALUES('Минск')")
statement.executeUpdate("INSERT INTO cities (name) VALUES('Москва')")
rs = statement.executeQuery("SELECT id, name FROM cities")
while(rs.next()) {
// read the result set
println "name = " + rs.getString("name")
println "id = " + rs.getInt("id")
}
statement.execute("SHUTDOWN")