Here you can find the source of getDataSource(String jndiName)
private static DataSource getDataSource(String jndiName) throws Exception
//package com.java2s; /*L// w w w . j a va 2 s . co m * Copyright Ekagra Software Technologies * * Distributed under the OSI-approved BSD 3-Clause License. * See http://ncip.github.com/common-logging-module/LICENSE.txt for details. */ import javax.naming.Context; import javax.naming.InitialContext; import javax.sql.DataSource; public class Main { private static DataSource getDataSource(String jndiName) throws Exception { Context ctx = new InitialContext(); if (ctx == null) { throw new Exception("No Context available"); } return (DataSource) ctx.lookup(jndiName); } }