Advertisement
Guest User

Untitled

a guest
Aug 29th, 2018
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. public class BookDbUtil {
  2.     private final DataSource dataSource;
  3.  
  4.     // constructor
  5.     public BookDbUtil() {
  6.         try {
  7.             /* TODO: przez adnotacje, albo jakos inaczej ladnie */
  8.             Context initContext = new InitialContext();
  9.             Context envContext = (Context) initContext.lookup("java:/comp/env");
  10.             dataSource = (DataSource) envContext.lookup("sql2226123");
  11.         } catch (NamingException e) {
  12.             throw new IllegalStateException("Could not initialize database", e);
  13.         }
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement