public static List < Note > getNotesList ( IHMConnection connection , float [ ] nswe ) throws Exception { String query = "SELECT " + // NotesTableFields . COLUMN_ID . getFieldName ( ) + ", " + // NotesTableFields . COLUMN_LON . getFieldName ( ) + ", " + // NotesTableFields . COLUMN_LAT . getFieldName ( ) + ", " + // NotesTableFields . COLUMN_ALTIM . getFieldName ( ) + ", " + // NotesTableFields . COLUMN_TEXT . getFieldName ( ) + ", " + // NotesTableFields . COLUMN_TS . getFieldName ( ) + ", " + // NotesTableFields . COLUMN_DESCRIPTION . getFieldName ( ) + // " FROM " + TABLE_NOTES ; if ( nswe != null ) { query = query + " WHERE (lon BETWEEN XXX AND XXX) AND (lat BETWEEN XXX AND XXX)" ; query = query . replaceFirst ( "XXX" , String . valueOf ( nswe [ 2 ] ) ) ; query = query . replaceFirst ( "XXX" , String . valueOf ( nswe [ 3 ] ) ) ; query = query . replaceFirst ( "XXX" , String . valueOf ( nswe [ 1 ] ) ) ; query = query . replaceFirst ( "XXX" , String . valueOf ( nswe [ 0 ] ) ) ; } List < Note > notes = new ArrayList <> ( ) ; try ( IHMStatement statement = connection . createStatement ( ) ; IHMResultSet rs = statement . executeQuery ( query ) ; ) { statement . setQueryTimeout ( 30 ) ; // set timeout to 30 sec. while ( rs . next ( ) ) { Note note = new Note ( ) ; note . id = rs . getLong ( 1 ) ; note . lon = rs . getDouble ( 2 ) ; note . lat = rs . getDouble ( 3 ) ; note . altim = rs . getDouble ( 4 ) ; note . simpleText = rs . getString ( 5 ) ; note . timeStamp = rs . getLong ( 6 ) ; note . description = rs . getString ( 7 ) ; notes . add ( note ) ; } } return notes ; }
Get the collected notes from the database inside a given bound .