public static PreparedStatement createTrackTable ( Connection connection , String trackTableName , boolean isH2 ) throws SQLException { try ( Statement stmt = connection . createStatement ( ) ) { StringBuilder sb = new StringBuilder ( "CREATE TABLE " ) ; sb . append ( trackTableName ) . append ( " (" ) ; if ( isH2 ) { sb . append ( "the_geom MULTILINESTRING CHECK ST_SRID(THE_GEOM) = 4326," ) ; } else { sb . append ( "the_geom GEOMETRY(MULTILINESTRING, 4326)," ) ; } sb . append ( " id INT," ) ; sb . append ( GPXTags . NAME . toLowerCase ( ) ) . append ( " TEXT," ) ; sb . append ( GPXTags . CMT . toLowerCase ( ) ) . append ( " TEXT," ) ; sb . append ( "description" ) . append ( " TEXT," ) ; sb . append ( GPXTags . SRC . toLowerCase ( ) ) . append ( " TEXT," ) ; sb . append ( GPXTags . HREF . toLowerCase ( ) ) . append ( " TEXT," ) ; sb . append ( GPXTags . HREFTITLE . toLowerCase ( ) ) . append ( " TEXT," ) ; sb . append ( GPXTags . NUMBER . toLowerCase ( ) ) . append ( " INT," ) ; sb . append ( GPXTags . TYPE . toLowerCase ( ) ) . append ( " TEXT," ) ; sb . append ( GPXTags . EXTENSIONS . toLowerCase ( ) ) . append ( " TEXT);" ) ; stmt . execute ( sb . toString ( ) ) ; } //We return the preparedstatement of the route table StringBuilder insert = new StringBuilder ( "INSERT INTO " ) . append ( trackTableName ) . append ( " VALUES ( ?" ) ; for ( int i = 1 ; i < GpxMetadata . RTEFIELDCOUNT ; i ++ ) { insert . append ( ",?" ) ; } insert . append ( ");" ) ; return connection . prepareStatement ( insert . toString ( ) ) ; }
Creat the track table