public static PreparedStatement createTrackSegmentsTable ( Connection connection , String trackSegementsTableName , boolean isH2 ) throws SQLException { try ( Statement stmt = connection . createStatement ( ) ) { StringBuilder sb = new StringBuilder ( "CREATE TABLE " ) ; sb . append ( trackSegementsTableName ) . append ( " (" ) ; if ( isH2 ) { sb . append ( "the_geom LINESTRING CHECK ST_SRID(THE_GEOM) = 4326," ) ; } else { sb . append ( "the_geom GEOMETRY(LINESTRING, 4326)," ) ; } sb . append ( " id INT," ) ; sb . append ( GPXTags . EXTENSIONS ) . append ( " TEXT," ) ; sb . append ( "id_track INT);" ) ; stmt . execute ( sb . toString ( ) ) ; } //We return the preparedstatement of the waypoints table StringBuilder insert = new StringBuilder ( "INSERT INTO " ) . append ( trackSegementsTableName ) . append ( " VALUES ( ?" ) ; for ( int i = 1 ; i < GpxMetadata . TRKSEGFIELDCOUNT ; i ++ ) { insert . append ( ",?" ) ; } insert . append ( ");" ) ; return connection . prepareStatement ( insert . toString ( ) ) ; }
Create the track segments table to store the segments of a track