public void initDB ( ) throws PlatformException { if ( _initScripts . isEmpty ( ) ) { createInitScripts ( ) ; } Project project = new Project ( ) ; TorqueSQLTask sqlTask = new TorqueSQLTask ( ) ; File outputDir = null ; try { outputDir = new File ( getWorkDir ( ) , "sql" ) ; outputDir . mkdir ( ) ; writeCompressedTexts ( outputDir , _initScripts ) ; project . setBasedir ( outputDir . getAbsolutePath ( ) ) ; // executing the generated sql, but this time with a torque task TorqueSQLExec sqlExec = new TorqueSQLExec ( ) ; TorqueSQLExec . OnError onError = new TorqueSQLExec . OnError ( ) ; sqlExec . setProject ( project ) ; onError . setValue ( "continue" ) ; sqlExec . setAutocommit ( true ) ; sqlExec . setDriver ( _jcd . getDriver ( ) ) ; sqlExec . setOnerror ( onError ) ; sqlExec . setUserid ( _jcd . getUserName ( ) ) ; sqlExec . setPassword ( _jcd . getPassWord ( ) == null ? "" : _jcd . getPassWord ( ) ) ; sqlExec . setUrl ( getDBManipulationUrl ( ) ) ; sqlExec . setSrcDir ( outputDir . getAbsolutePath ( ) ) ; sqlExec . setSqlDbMap ( SQL_DB_MAP_NAME ) ; sqlExec . execute ( ) ; deleteDir ( outputDir ) ; } catch ( Exception ex ) { // clean-up if ( outputDir != null ) { deleteDir ( outputDir ) ; } throw new PlatformException ( ex ) ; } }
Creates the tables according to the schema files .