private Connection createConnection ( ) { if ( mConnInfo != null ) { DBConnCreator dbConnCreator = new DBConnCreator ( mConnInfo ) ; Connection conn = dbConnCreator . createDBConnection ( ) ; return conn ; } else if ( mDbcpPropertyFile != null ) { Properties properties = new Properties ( ) ; InputStream is = Thread . currentThread ( ) . getContextClassLoader ( ) . getResourceAsStream ( mDbcpPropertyFile ) ; try { properties . load ( is ) ; DataSource ds ; ds = BasicDataSourceFactory . createDataSource ( properties ) ; Connection conn = ds . getConnection ( ) ; return conn ; } catch ( IOException e ) { e . printStackTrace ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } return null ; }
Get the DB connection