Version 8 (modified by 18 years ago) (diff) | ,
---|
Using SQLite database
UTGB Core supports SQLite3 database access. In the default setting, the database files within utgb-core/resource folder can be accessed from UTGB core.
After launching the GWTShell, try the following URL:
The source code of this servlet is here: source:trunk/utgb/utgb-core/src/main/java/org/utgenome/gwt/utgb/server/app/SQLiteAccessSample.java
Simple SQL query processing with BeanUtil?
Prepare a bean class with appropriate getter/setters;
public class Person { int id; String name; public Person() {} public int getId() { return id; } public String getName() { return name; } public void setId(int id) { return id; } public void setName(String name) { return name; } }
Sample Table data (person table):
person_id | name |
1 | leo |
2 | yui |
Table data retrieval:
SQLiteAccess sqlite = UTGB.getSQLiteAccess("sqlite3databasefile.db"); List<Person> personList = sqlite.query("select person_id as id, name from person", Person.class); // personList contains Person(1, leo), Person(2, yui)