public void createDB ( ) throws PlatformException { if ( _creationScript == null ) { createCreationScript ( ) ; } Project project = new Project ( ) ; TorqueDataModelTask modelTask = new TorqueDataModelTask ( ) ; File tmpDir = null ; File scriptFile = null ; try { tmpDir = new File ( getWorkDir ( ) , "schemas" ) ; tmpDir . mkdir ( ) ; scriptFile = new File ( tmpDir , CREATION_SCRIPT_NAME ) ; writeCompressedText ( scriptFile , _creationScript ) ; project . setBasedir ( tmpDir . getAbsolutePath ( ) ) ; // we use the ant task 'sql' to perform the creation script SQLExec sqlTask = new SQLExec ( ) ; SQLExec . OnError onError = new SQLExec . OnError ( ) ; onError . setValue ( "continue" ) ; sqlTask . setProject ( project ) ; sqlTask . setAutocommit ( true ) ; sqlTask . setDriver ( _jcd . getDriver ( ) ) ; sqlTask . setOnerror ( onError ) ; sqlTask . setUserid ( _jcd . getUserName ( ) ) ; sqlTask . setPassword ( _jcd . getPassWord ( ) == null ? "" : _jcd . getPassWord ( ) ) ; sqlTask . setUrl ( getDBCreationUrl ( ) ) ; sqlTask . setSrc ( scriptFile ) ; sqlTask . execute ( ) ; deleteDir ( tmpDir ) ; } catch ( Exception ex ) { // clean-up if ( ( tmpDir != null ) && tmpDir . exists ( ) ) { try { scriptFile . delete ( ) ; } catch ( NullPointerException e ) { LoggerFactory . getLogger ( this . getClass ( ) ) . error ( "NPE While deleting scriptFile [" + scriptFile . getName ( ) + "]" , e ) ; } } throw new PlatformException ( ex ) ; } }
Creates the database .