All Downloads are FREE. Search and download functionalities are using the official Maven repository.

se.ugli.habanero.j.datasource.JndiDataSource Maven / Gradle / Ivy

There is a newer version: 1.8.1.1
Show newest version
package se.ugli.habanero.j.datasource;

import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

import se.ugli.habanero.j.HabaneroException;

public class JndiDataSource extends DataSourceDelegate {

	public JndiDataSource(final String jndiDataSourceName) {
		super(lookupDataSource(jndiDataSourceName));
	}

	private static DataSource lookupDataSource(final String jndiDataSourceName) {
		try {
			final InitialContext context = new InitialContext();
			return (DataSource) context.lookup(jndiDataSourceName);
		} catch (final NamingException e) {
			throw new HabaneroException(e);
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy