Java DataSource getDataSource(String jndiName)

Here you can find the source of getDataSource(String jndiName)

Description

get Data Source

License

BSD License

Declaration

private static DataSource getDataSource(String jndiName) throws Exception 

Method Source Code

//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);
    }
}

Related

  1. getConnection(DataSource dataSource)
  2. getConnection(final DataSource ds, final boolean autoCommit)
  3. getConnectionFromDataSource(DataSource ds)
  4. getDatabaseName(DataSource dataSource)
  5. getDataSource(String jndi)
  6. getDataSource(String service)
  7. getDataSourceCache(String hostName)
  8. getDBConnection(DataSource dataSource)
  9. getGlobalVariable(DataSource dataSource, String variable)