本文整理汇总了Java中org.springframework.jdbc.datasource.SingleConnectionDataSource.setUrl方法的典型用法代码示例。如果您正苦于以下问题:Java SingleConnectionDataSource.setUrl方法的具体用法?Java SingleConnectionDataSource.setUrl怎么用?Java SingleConnectionDataSource.setUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.jdbc.datasource.SingleConnectionDataSource
的用法示例。
在下文中一共展示了SingleConnectionDataSource.setUrl方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateSQL
import org.springframework.jdbc.datasource.SingleConnectionDataSource; //导入方法依赖的package包/类
private boolean validateSQL(JobVO jobVO) {
SingleConnectionDataSource ds = new SingleConnectionDataSource();
try {
ds.setDriverClassName(jobVO.getDriverClassName());
ds.setUrl(jobVO.getUrl());
ds.setUsername(jobVO.getUsername());
ds.setPassword(jobVO.getPassword());
JdbcTemplate template = new JdbcTemplate(ds);
template.execute(jobVO.getSql());
return true;
} catch (Throwable t) {
return false;
} finally {
ds.destroy();
}
}
示例2: getSingleConnectionDataSource
import org.springframework.jdbc.datasource.SingleConnectionDataSource; //导入方法依赖的package包/类
public SingleConnectionDataSource getSingleConnectionDataSource(String code) throws Exception {
//String sql ="select t2.DRIVER_CLASS as driver,t2.url ,t2.user_name ,t2.password from SYS_DATA_SOURCE t1,sys_db_links t2 where t1.link_id=t2.link_id and t1.code='"+code+"'";
String sql ="select t2.DRIVER_CLASS as driver,t2.url ,t2.user_name ,t2.password from SYS_DATA_SOURCE t1,sys_db_links t2 where t1.link_id=t2.link_id and t1.sh_code='"+code+"'";
List<Map<String,Object>> list = (List<Map<String,Object>>)this.jdbcTemplate.queryForList(sql);
Map<String,Object> map = new HashMap<String,Object>();
if(list.size()>0){
map = list.get(0);
}
SingleConnectionDataSource ds = new SingleConnectionDataSource();
ds.setDriverClassName(ParseUtil.getString(map.get("driver")));
ds.setUrl(ParseUtil.getString(map.get("url")));
ds.setUsername(ParseUtil.getString(map.get("user_name")));
ds.setPassword(ParseUtil.getString(map.get("password")));
return ds;
}
示例3: getDataSourceFrom
import org.springframework.jdbc.datasource.SingleConnectionDataSource; //导入方法依赖的package包/类
public static SingleConnectionDataSource getDataSourceFrom(String databaseFile) {
SingleConnectionDataSource dataSource = new SingleConnectionDataSource();
dataSource.setDriverClassName("org.sqlite.JDBC");
dataSource.setUrl("jdbc:sqlite:" + databaseFile);
return dataSource;
}