本文整理汇总了Java中org.apache.ibatis.datasource.DataSourceException类的典型用法代码示例。如果您正苦于以下问题:Java DataSourceException类的具体用法?Java DataSourceException怎么用?Java DataSourceException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataSourceException类属于org.apache.ibatis.datasource包,在下文中一共展示了DataSourceException类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setProperties
import org.apache.ibatis.datasource.DataSourceException; //导入依赖的package包/类
@Override
public void setProperties(Properties properties) {
try {
InitialContext initCtx;
Properties env = getEnvProperties(properties);
if (env == null) {
initCtx = new InitialContext();
} else {
initCtx = new InitialContext(env);
}
if (properties.containsKey(INITIAL_CONTEXT)
&& properties.containsKey(DATA_SOURCE)) {
Context ctx = (Context) initCtx.lookup(properties.getProperty(INITIAL_CONTEXT));
dataSource = (DataSource) ctx.lookup(properties.getProperty(DATA_SOURCE));
} else if (properties.containsKey(DATA_SOURCE)) {
dataSource = (DataSource) initCtx.lookup(properties.getProperty(DATA_SOURCE));
}
} catch (NamingException e) {
throw new DataSourceException("There was an error configuring JndiDataSourceTransactionPool. Cause: " + e, e);
}
}
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:24,代码来源:JndiDataSourceFactory.java
示例2: shouldInstantiateAndThrowAllCustomExceptions
import org.apache.ibatis.datasource.DataSourceException; //导入依赖的package包/类
@Test
public void shouldInstantiateAndThrowAllCustomExceptions() throws Exception {
Class<?>[] exceptionTypes = {
BindingException.class,
CacheException.class,
DataSourceException.class,
ExecutorException.class,
LogException.class,
ParsingException.class,
BuilderException.class,
PluginException.class,
ReflectionException.class,
PersistenceException.class,
SqlSessionException.class,
TransactionException.class,
TypeException.class,
ScriptingException.class
};
for (Class<?> exceptionType : exceptionTypes) {
testExceptionConstructors(exceptionType);
}
}
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:24,代码来源:GeneralExceptionsTest.java
示例3: setProperties
import org.apache.ibatis.datasource.DataSourceException; //导入依赖的package包/类
@Override
public void setProperties(Properties properties) {
try {
InitialContext initCtx = null;
Properties env = getEnvProperties(properties);
if (env == null) {
initCtx = new InitialContext();
} else {
initCtx = new InitialContext(env);
}
if (properties.containsKey(INITIAL_CONTEXT)
&& properties.containsKey(DATA_SOURCE)) {
Context ctx = (Context) initCtx.lookup(properties.getProperty(INITIAL_CONTEXT));
dataSource = (DataSource) ctx.lookup(properties.getProperty(DATA_SOURCE));
} else if (properties.containsKey(DATA_SOURCE)) {
dataSource = (DataSource) initCtx.lookup(properties.getProperty(DATA_SOURCE));
}
} catch (NamingException e) {
throw new DataSourceException("There was an error configuring JndiDataSourceTransactionPool. Cause: " + e, e);
}
}
开发者ID:txazo,项目名称:mybatis,代码行数:24,代码来源:JndiDataSourceFactory.java
示例4: setProperties
import org.apache.ibatis.datasource.DataSourceException; //导入依赖的package包/类
@Override
public void setProperties(Properties properties) {
try {
InitialContext initCtx = null;
Properties env = getEnvProperties(properties);
if (env == null) {
initCtx = new InitialContext();
} else {
initCtx = new InitialContext(env);
}
if (properties.containsKey(INITIAL_CONTEXT)
&& properties.containsKey(DATA_SOURCE)) {
//从JNDI上下文中找到DataSource并返回
Context ctx = (Context) initCtx.lookup(properties.getProperty(INITIAL_CONTEXT));
dataSource = (DataSource) ctx.lookup(properties.getProperty(DATA_SOURCE));
} else if (properties.containsKey(DATA_SOURCE)) {
//从JNDI上下文中找到DataSource并返回
dataSource = (DataSource) initCtx.lookup(properties.getProperty(DATA_SOURCE));
}
} catch (NamingException e) {
throw new DataSourceException("There was an error configuring JndiDataSourceTransactionPool. Cause: " + e, e);
}
}
开发者ID:toulezu,项目名称:play,代码行数:26,代码来源:JndiDataSourceFactory.java
示例5: setProperties
import org.apache.ibatis.datasource.DataSourceException; //导入依赖的package包/类
@Override
public void setProperties(final Properties properties) {
final Properties driverProperties = new Properties();
final MetaObject metaDataSource = SystemMetaObject.forObject(dataSource);
for (final Object key : properties.keySet()) {
final String propertyName = (String) key;
if (metaDataSource.hasSetter(propertyName)) {
final String value = (String) properties.get(propertyName);
/** 对没有设置值的属性跳过设置 */
if (StringUtils.isNotEmpty(value) && value.startsWith("${") && value.endsWith("}")) {
continue;
}
final Object convertedValue = convertValue(metaDataSource, propertyName, value);
metaDataSource.setValue(propertyName, convertedValue);
} else {
throw new DataSourceException("Unknown DataSource property: " + propertyName);
}
}
if (driverProperties.size() > 0) {
metaDataSource.setValue("driverProperties", driverProperties);
}
}
开发者ID:nano-projects,项目名称:nano-framework,代码行数:25,代码来源:AbstractDataSourceFactory.java
示例6: createJndiDataSource
import org.apache.ibatis.datasource.DataSourceException; //导入依赖的package包/类
private void createJndiDataSource() throws Exception {
try {
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, TEST_INITIAL_CONTEXT_FACTORY);
MockContext ctx = new MockContext(false);
ctx.bind(TEST_DATA_SOURCE, expectedDataSource);
InitialContext initCtx = new InitialContext(env);
initCtx.bind(TEST_INITIAL_CONTEXT, ctx);
} catch (NamingException e) {
throw new DataSourceException("There was an error configuring JndiDataSourceTransactionPool. Cause: " + e, e);
}
}
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:15,代码来源:JndiDataSourceFactoryTest.java
示例7: C3P0DataSourceFactory
import org.apache.ibatis.datasource.DataSourceException; //导入依赖的package包/类
public C3P0DataSourceFactory() {
try {
Class<?> comboPooledDataSource = Class.forName("com.mchange.v2.c3p0.ComboPooledDataSource");
this.dataSource = (DataSource) comboPooledDataSource.newInstance();
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) {
throw new DataSourceException(e.getMessage(), e);
}
}
开发者ID:nano-projects,项目名称:nano-framework,代码行数:9,代码来源:C3P0DataSourceFactory.java
示例8: TomcatJdbcPoolDataSourceFactory
import org.apache.ibatis.datasource.DataSourceException; //导入依赖的package包/类
public TomcatJdbcPoolDataSourceFactory() {
try {
tomcatJdbcDataSource = Class.forName("org.apache.tomcat.jdbc.pool.DataSource");
this.dataSource = (DataSource) tomcatJdbcDataSource.newInstance();
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) {
throw new DataSourceException(e.getMessage(), e);
}
}
开发者ID:nano-projects,项目名称:nano-framework,代码行数:9,代码来源:TomcatJdbcPoolDataSourceFactory.java
示例9: DruidDataSourceFactory
import org.apache.ibatis.datasource.DataSourceException; //导入依赖的package包/类
public DruidDataSourceFactory() {
try {
Class<?> druidDataSource = Class.forName("com.alibaba.druid.pool.DruidDataSource");
this.dataSource = (DataSource) druidDataSource.newInstance();
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) {
throw new DataSourceException(e.getMessage(), e);
}
}
开发者ID:nano-projects,项目名称:nano-framework,代码行数:9,代码来源:DruidDataSourceFactory.java
注:本文中的org.apache.ibatis.datasource.DataSourceException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论