private Connection getConnectionFromDataSource ( String jndiName , Class < ? extends JdbcControl . JndiContextFactory > jndiFactory ) throws SQLException { Connection con = null ; try { JndiContextFactory jf = ( JndiContextFactory ) jndiFactory . newInstance ( ) ; Context jndiContext = jf . getContext ( ) ; _dataSource = ( DataSource ) jndiContext . lookup ( jndiName ) ; con = _dataSource . getConnection ( ) ; } catch ( IllegalAccessException iae ) { throw new ControlException ( "IllegalAccessException:" , iae ) ; } catch ( InstantiationException ie ) { throw new ControlException ( "InstantiationException:" , ie ) ; } catch ( NamingException ne ) { throw new ControlException ( "NamingException:" , ne ) ; } return con ; }
Get a connection from a DataSource .