그런 후에 개발을 해야겠죠... 저 같은 경우는 간단한 소스로 테스트를 했습니다.
01 | import com.google.gwt.gears.core.client.GearsException; |
02 | import com.google.gwt.gears.database.client.Database; |
03 | import com.google.gwt.gears.database.client.DatabaseException; |
04 | import com.google.gwt.gears.database.client.ResultSet; |
06 | public class GearsPortal { |
08 | private static GearsPortal instance; |
10 | public static GearsPortal getInstance() { |
12 | instance = new GearsPortal(); |
16 | private static final String DATABASE_NAME = "wiseone_db" ; |
18 | private Database database; |
20 | public GearsPortal() { |
25 | private void initDatabase() { |
27 | database = new Database(DATABASE_NAME); |
29 | catch (GearsException e) { |
35 | private void createTable() { |
37 | database.execute( "CREATE TABLE IF NOT EXISTS TPT3010(userIndex text, portalInfo text)" ); |
39 | catch (DatabaseException e) { |
44 | protected Database getDatabase() { |
48 | public String getPortalInfo(String userIndex) { |
49 | String portalInfo = null ; |
52 | ResultSet rs = getDatabase().execute( "SELECT portalInfo FROM TPT3010 WHERE userIndex = ?" , new String[] { userIndex }); |
53 | portalInfo = rs.getFieldAsString( 0 ); |
55 | catch (DatabaseException e) { |
62 | public void setPortalInfo(String userIndex, String portalInfo) { |
64 | if (getPortalInfo(userIndex) == null ) { |
65 | getDatabase().execute( "INSERT INTO TPT3010 VALUES( ?, ? )" , new String[] { userIndex, portalInfo }); |
66 | System.out.println( "insert data" ); |
68 | getDatabase().execute( "UPDATE TPT3010 SET portalInfo = ? WHERE userIndex = ?" , new String[] { portalInfo, userIndex }); |
69 | System.out.println( "update data" ); |
72 | catch (DatabaseException e) { |
일반적인 gears 시에 factory 를 통해서 database 객체를 가지고 오는데 캡슐화 되어 있어서
Database 를 open 하고 table 을 생성한 후에 사용하면 됩니다.
좀 아쉬운 점은 executeList 가 없다는 점... 나중에 시간나면 포럼에 글 올리거나 직접 수정해야겠네요~