public void process ( Connection connection , String directory ) throws Exception { connection . setAutoCommit ( true ) ; // // Retrieve meta data about the connection // DatabaseMetaData dmd = connection . getMetaData ( ) ; String [ ] types = { "TABLE" } ; FileWriter fw = new FileWriter ( directory ) ; PrintWriter pw = new PrintWriter ( fw ) ; pw . println ( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" ) ; pw . println ( ) ; pw . println ( "<database>" ) ; ResultSet tables = dmd . getTables ( null , null , null , types ) ; while ( tables . next ( ) == true ) { processTable ( pw , connection , tables . getString ( "TABLE_NAME" ) ) ; } pw . println ( "</database>" ) ; pw . close ( ) ; tables . close ( ) ; }
Export data base contents to a directory using supplied connection .