public static void createTables ( Connection connection ) throws IOException , SQLException { StringBuilder sB = new StringBuilder ( ) ; sB . append ( "CREATE TABLE " ) ; sB . append ( TABLE_BOOKMARKS ) ; sB . append ( " (" ) ; sB . append ( COLUMN_ID ) ; sB . append ( " INTEGER PRIMARY KEY, " ) ; sB . append ( COLUMN_LON ) . append ( " REAL NOT NULL, " ) ; sB . append ( COLUMN_LAT ) . append ( " REAL NOT NULL," ) ; sB . append ( COLUMN_ZOOM ) . append ( " REAL NOT NULL," ) ; sB . append ( COLUMN_NORTHBOUND ) . append ( " REAL NOT NULL," ) ; sB . append ( COLUMN_SOUTHBOUND ) . append ( " REAL NOT NULL," ) ; sB . append ( COLUMN_WESTBOUND ) . append ( " REAL NOT NULL," ) ; sB . append ( COLUMN_EASTBOUND ) . append ( " REAL NOT NULL," ) ; sB . append ( COLUMN_TEXT ) . append ( " TEXT NOT NULL " ) ; sB . append ( ");" ) ; String CREATE_TABLE_BOOKMARKS = sB . toString ( ) ; sB = new StringBuilder ( ) ; sB . append ( "CREATE INDEX bookmarks_x_by_y_idx ON " ) ; sB . append ( TABLE_BOOKMARKS ) ; sB . append ( " ( " ) ; sB . append ( COLUMN_LON ) ; sB . append ( ", " ) ; sB . append ( COLUMN_LAT ) ; sB . append ( " );" ) ; String CREATE_INDEX_BOOKMARKS_X_BY_Y = sB . toString ( ) ; try ( Statement statement = connection . createStatement ( ) ) { statement . setQueryTimeout ( 30 ) ; // set timeout to 30 sec. statement . executeUpdate ( CREATE_TABLE_BOOKMARKS ) ; statement . executeUpdate ( CREATE_INDEX_BOOKMARKS_X_BY_Y ) ; } catch ( Exception e ) { throw new IOException ( e . getLocalizedMessage ( ) ) ; } }
Create bookmarks tables .