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

cn.hutool.db.ds.jndi.JndiDSFactory Maven / Gradle / Ivy

Go to download

Hutool是一个小而全的Java工具类库,通过静态方法封装,降低相关API的学习成本,提高工作效率,使Java拥有函数式语言般的优雅,让Java语言也可以“甜甜的”。

There is a newer version: 5.8.34
Show newest version
package cn.hutool.db.ds.jndi;

import javax.sql.DataSource;

import cn.hutool.core.util.StrUtil;
import cn.hutool.db.DbRuntimeException;
import cn.hutool.db.DbUtil;
import cn.hutool.db.ds.AbstractDSFactory;
import cn.hutool.setting.Setting;

/**
 * JNDI数据源工厂类
* Setting配置样例:
* ---------------------
* [group]
* jndi = jdbc/TestDB
* ---------------------
* * @author Looly * */ public class JndiDSFactory extends AbstractDSFactory { private static final long serialVersionUID = 1573625812927370432L; public static final String DS_NAME = "JNDI DataSource"; public JndiDSFactory() { this(null); } public JndiDSFactory(Setting setting) { super(DS_NAME, DataSource.class, setting); } @Override protected DataSource createDataSource(String jdbcUrl, String driver, String user, String pass, Setting poolSetting) { String jndiName = poolSetting.getStr("jndi"); if (StrUtil.isEmpty(jndiName)) { throw new DbRuntimeException("No setting name [jndi] for this group."); } return DbUtil.getJndiDs(jndiName); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy