private void createDatabaseIfNotExist ( boolean drop ) throws URISyntaxException , IOException , ClientProtocolException { boolean exist = checkForDBExistence ( ) ; if ( exist && drop ) { dropDatabase ( ) ; exist = false ; } if ( ! exist ) { URI uri = new URI ( CouchDBConstants . PROTOCOL , null , httpHost . getHostName ( ) , httpHost . getPort ( ) , CouchDBConstants . URL_SEPARATOR + databaseName . toLowerCase ( ) , null , null ) ; HttpPut put = new HttpPut ( uri ) ; HttpResponse putRes = null ; try { // creating database. putRes = httpClient . execute ( httpHost , put , CouchDBUtils . getContext ( httpHost ) ) ; } finally { CouchDBUtils . closeContent ( putRes ) ; } } }
Creates the database if not exist .