Guest User

Untitled

a guest
Jun 12th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. public class JBossDatasourceTest {
  2.  
  3. @Before
  4. public void initialize() {
  5. try {
  6.  
  7. System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
  8. "org.apache.naming.java.javaURLContextFactory");
  9. System.setProperty(Context.URL_PKG_PREFIXES,
  10. "org.apache.naming");
  11.  
  12. InitialContext context = new InitialContext();
  13. context.createSubcontext("java:");
  14. context.createSubcontext("java:/datasourceName");
  15.  
  16. OracleConnectionPoolDataSource poolDataSource = new OracleConnectionPoolDataSource();
  17. poolDataSource.setURL("jdbc:oracle:thin:@localhost:1521:db");
  18. poolDataSource.setUser("user");
  19. poolDataSource.setPassword("password");
  20.  
  21. context.rebind("java:/datasourceName", poolDataSource);
  22.  
  23. }catch(NamingException | SQLException e) {
  24. e.printStackTrace();
  25. }
  26. }
  27. }
Add Comment
Please, Sign In to add comment