Skip to content

Instantly share code, notes, and snippets.

@inancsevinc
Created April 12, 2012 13:35
Show Gist options
  • Save inancsevinc/2367302 to your computer and use it in GitHub Desktop.
Save inancsevinc/2367302 to your computer and use it in GitHub Desktop.
@BeforeClass method responsible for creating jndi datasource for oracle
@BeforeClass
public static void setUpClass() throws Exception {
try {
System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.naming.java.javaURLContextFactory");
System.setProperty(Context.URL_PKG_PREFIXES, "org.apache.naming");
InitialContext ic = new InitialContext();
ic.createSubcontext("jdbc");
// Construct DataSource
OracleConnectionPoolDataSource ds = new OracleConnectionPoolDataSource();
ds.setURL(DB_URL);
ds.setUser(DB_USERNAME);
ds.setPassword(DB_PASSWORD);
ic.bind(DATASOURCE_JNDI_NAME, ds);
} catch (Exception ex) {
ex.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment