Example usage for javax.naming InitialContext lookup

List of usage examples for javax.naming InitialContext lookup

Introduction

In this page you can find the example usage for javax.naming InitialContext lookup.

Prototype

public Object lookup(Name name) throws NamingException 

Source Link

Usage

From source file:com.portfolio.data.provider.MysqlAdminProvider.java

@Override
public void connect(Properties connectionProperties) throws Exception {

    InitialContext cxt = new InitialContext();
    if (cxt == null) {
        throw new Exception("no context found!");
    }/* ww w  .j a  va  2 s  .co m*/

    DataSource ds = (DataSource) cxt.lookup("java:/comp/env/jdbc/portfolio-backend");

    if (ds == null) {
        throw new Exception("Data  jdbc/portfolio-backend source not found!");
    }
    connection = ds.getConnection();

}