public static void writePRJ ( Connection connection , int srid , File fileName ) throws SQLException , FileNotFoundException { if ( srid != 0 ) { StringBuilder sb = new StringBuilder ( "SELECT SRTEXT FROM " ) ; sb . append ( "PUBLIC.SPATIAL_REF_SYS " ) . append ( " WHERE SRID = ?" ) ; PreparedStatement ps = connection . prepareStatement ( sb . toString ( ) ) ; ps . setInt ( 1 , srid ) ; PrintWriter printWriter = null ; ResultSet rs = null ; try { rs = ps . executeQuery ( ) ; if ( rs . next ( ) ) { printWriter = new PrintWriter ( fileName ) ; printWriter . println ( rs . getString ( 1 ) ) ; } else { log . warn ( "This SRID { " + srid + " } is not supported. \n The PRJ file won't be created." ) ; } } finally { if ( printWriter != null ) { printWriter . close ( ) ; } if ( rs != null ) { rs . close ( ) ; } ps . close ( ) ; } } }
Write a prj file according a given SRID code .