@ SuppressWarnings ( "nls" ) private void doInit ( ) { QueryRunner run = new QueryRunner ( ds ) ; Boolean isInitialized ; try { isInitialized = run . query ( "SELECT * FROM gw_apis" , new ResultSetHandler < Boolean > ( ) { @ Override public Boolean handle ( ResultSet rs ) throws SQLException { return true ; } } ) ; } catch ( SQLException e ) { isInitialized = false ; } if ( isInitialized ) { System . out . println ( "============================================" ) ; System . out . println ( "Apiman Gateway database already initialized." ) ; System . out . println ( "============================================" ) ; return ; } ClassLoader cl = JdbcInitializer . class . getClassLoader ( ) ; URL resource = cl . getResource ( "ddls/apiman-gateway_" + dbType + ".ddl" ) ; try ( InputStream is = resource . openStream ( ) ) { System . out . println ( "=======================================" ) ; System . out . println ( "Initializing apiman Gateway database." ) ; DdlParser ddlParser = new DdlParser ( ) ; List < String > statements = ddlParser . parse ( is ) ; for ( String sql : statements ) { System . out . println ( sql ) ; run . update ( sql ) ; } System . out . println ( "=======================================" ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Do the initialization work .