public void createDB ( String dbName ) { assertNotEmpty ( dbName , "dbName" ) ; InputStream getresp = null ; HttpResponse putresp = null ; final URI uri = buildUri ( dbc . getBaseUri ( ) ) . path ( dbName ) . build ( ) ; try { getresp = dbc . get ( uri ) ; } catch ( NoDocumentException e ) { // db doesn't exist final HttpPut put = new HttpPut ( uri ) ; putresp = dbc . executeRequest ( put ) ; log . info ( String . format ( "Created Database: '%s'" , dbName ) ) ; } finally { close ( getresp ) ; close ( putresp ) ; } }
Requests CouchDB creates a new database ; if one doesn t exist .