This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
That all depends. If you are doing your own JDBC calls then yes you must have some code like that to obtain a connection. If you are using JPA entity beans, however, you do not have to write that code (instead you configure the entity manager to indicate which datasource to use). Or you could use an @Resource annotation to inject the data source.