public static SQLService getInstance ( ) throws Exception { if ( _instance == null ) { _instance = new SQLService ( ) ; _instance . startServer ( ) ; // default pool size is 20 // can be overriden by env variable int dbPool = 20 ; if ( Utils . getEnvironmentOptionValue ( Constants . SYS_DATABASE_POOL_SIZE ) != null ) { dbPool = Integer . valueOf ( Utils . getEnvironmentOptionValue ( Constants . SYS_DATABASE_POOL_SIZE ) ) ; } // initialize connection pool PoolProperties p = new PoolProperties ( ) ; String connectString = "jdbc:h2:tcp://" + _instance . databaseHost + ":" + String . valueOf ( _instance . port ) + "/" + _instance . databaseName + "/proxydb;MULTI_THREADED=true;AUTO_RECONNECT=TRUE;AUTOCOMMIT=ON" ; p . setUrl ( connectString ) ; p . setDriverClassName ( "org.h2.Driver" ) ; p . setUsername ( "sa" ) ; p . setJmxEnabled ( true ) ; p . setTestWhileIdle ( false ) ; p . setTestOnBorrow ( true ) ; p . setValidationQuery ( "SELECT 1" ) ; p . setTestOnReturn ( false ) ; p . setValidationInterval ( 5000 ) ; p . setTimeBetweenEvictionRunsMillis ( 30000 ) ; p . setMaxActive ( dbPool ) ; p . setInitialSize ( 5 ) ; p . setMaxWait ( 30000 ) ; p . setRemoveAbandonedTimeout ( 60 ) ; p . setMinEvictableIdleTimeMillis ( 30000 ) ; p . setMinIdle ( 10 ) ; p . setLogAbandoned ( true ) ; p . setRemoveAbandoned ( true ) ; _instance . datasource = new DataSource ( ) ; _instance . datasource . setPoolProperties ( p ) ; } return _instance ; }
Obtain instance of the SQL Service