Mondiran创建连接
Class. forName(driver);
connection = DriverManager. getConnection(url , username ,password );
Class. forName(driver);
connection = DriverManager. getConnection(url , username ,password );
OlapConnection olapConnection = connection.unwrap(OlapConnection.class);
user=root&password=root;Catalog=C:\\Users\\Administrator\\Desktop\\nrtp\\FoodMart.xml;能够看出url中的每一项是通过";"切割的,类似于mysql的开头是"jdbc:mysql",mondrian连接的url的开头必须是"jdbc:mondrian:",另外还包含"Jdbc"和"Catalog"属性字段。在DriverManager的getConnection静态方法中运行例如以下操作:
public static Connection getConnection(String url,
String user, String password) throws SQLException {
java.util.Properties info = new java.util.Properties();
if (user != null) {
info.put("user", user);
}
if (password != null) {
info.put("password", password);
}
return (getConnection(url, info, Reflection.getCallerClass()));
}
private static Connection getConnection(
String url, java.util.Properties info, Class<? > caller) throws SQLException {
/*
* When callerCl is null, we should check the application's
* (which is invoking this class indirectly)
* classloader, so that the JDBC driver class outside rt.jar
* can be loaded from here.
*/
ClassLoader callerCL = caller != null ? caller.getClassLoader() : null;
synchronized (DriverManager.class) {
// synchronize loading of the correct classloader.
if (callerCL == null) {
callerCL = Thread.currentThread().getContextClassLoader();
}
} if(url == null) {
throw new SQLException("The url cannot be null", "08001");
} println("DriverManager.getConnection(\"" + url + "\")"); // Walk through the loaded registeredDrivers attempting to make a connection.
// Remember the first exception that gets raised so we can reraise it.
SQLException reason = null; for(DriverInfo aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then
// skip it.
if(isDriverAllowed(aDriver.driver, callerCL)) {
try {
println(" trying " + aDriver.driver.getClass().getName());
Connection con = aDriver.driver.connect(url, info);
if (con != null) {
// Success!
println("getConnection returning " + aDriver.driver.getClass().getName());
return (con);
}
} catch (SQLException ex) {
if (reason == null) {
reason = ex;
}
}
} else {
println(" skipping: " + aDriver.getClass().getName());
} }
// if we got here nobody could connect.
if (reason != null) {
println("getConnection failed: " + reason);
throw reason;
} println("getConnection: no suitable driver found for "+ url);
throw new SQLException("No suitable driver found for "+ url, "08001");
}
static {
try {
register();
} catch (SQLException e) {
e.printStackTrace();
}
}
我想其他的driver类(包含mysql、oracle等)都应该使用这样的方式吧。
MondrianOlap4jDriver类中创建connection的方法例如以下:
public Connection connect(String url, Properties info) throws SQLException {
if (!MondrianOlap4jConnection.acceptsURL(url)) {
return null;
}
return factory.newConnection(this, url, info);
}
driver,String url,Properties info) throws
SQLException
this.mondrianConnection = (RolapConnection) mondrian.olap.DriverManager .getConnection(list, null);
server,Util.PropertyList connectInfo,RolapSchema schema,DataSource
dataSource),參数分别为指定的server、URL的配置信息,使用的Schema对象,这里为null,指定的datasource信息,这里为null。
"sun.jdbc.odbc.JdbcOdbcDriver,org.hsqldb.jdbcDriver,oracle.jdbc.OracleDriver,com.mysql.jdbc.Driver"(load之前会推断是否已经载入),接着再从URL中查找全部数据源jdbc连接的參数。这些參数是通过jdbc.xxx=yyy指定的。当中xxx为參数名。yyy为參数值。
接着再依据URL中指定的"PoolNeeded"參数已决定是否创建一个datasource池,默认情况下是对于使用指定Jdbc创建的数据源会创建这个池子,而对于通过DataSource參数指定的数据源则不创建。这时候创建的DataSource对象分成了四种情况(当Jdbc和DataSource同一时候指定的时候使用Jdbc):
此外Schema构造函数还会创建AggTableManager对象和DataSourceChangeListener对象。
h, m, s, ms。
Mondiran创建连接的更多相关文章
- ASP.NET MVC 5 - 创建连接字符串(Connection String)并使用SQL Server LocalDB
您创建的MovieDBContext类负责处理连接到数据库,并将Movie对象映射到数据库记录的任务中.你可能会问一个问题,如何指定它将连接到数据库? 实际上,确实没有指定要使用的数据库,Entity ...
- 《Entity Framework 6 Recipes》中文翻译系列 (38) ------ 第七章 使用对象服务之动态创建连接字符串和从数据库读取模型
翻译的初衷以及为什么选择<Entity Framework 6 Recipes>来学习,请看本系列开篇 第七章 使用对象服务 本章篇幅适中,对真实应用中的常见问题提供了切实可行的解决方案. ...
- HTTPS-HSTS协议(强制客户端使用HTTPS与服务器创建连接)
HSTS(HTTP Strict Transport Security)国际互联网工程组织IETE正在推行一种新的Web安全协议 HSTS的作用是强制客户端(如浏览器)使用HTTPS与服务器创建连接. ...
- JDBC 创建连接对象的三种方式 、 properties文件的建立、编辑和信息获取
创建连接对象的三种方式 //第一种方式 Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/ ...
- Oracle--SQL Developer创建连接及使用
安装好Oracle之后,有几种方式可以来管理Oracle中的数据库,首先就是登陆网页版的界面:https://localhost:1158/em,这种方式管理的东西太多,使用起来有点不方便,第二种方式 ...
- ASP.NET MVC 5 学习教程:创建连接字符串
原文 ASP.NET MVC 5 学习教程:创建连接字符串 起飞网 ASP.NET MVC 5 学习教程目录: 添加控制器 添加视图 修改视图和布局页 控制器传递数据给视图 添加模型 创建连接字符串 ...
- ADO.NET 1创建连接、执行命令
一无参构造函数的形式: 创建连接.创建命令.执行命令: string connstr = @"server=.;database=TestDataBase;uid=sa;pwd=130988 ...
- 【译】ASP.NET MVC 5 教程 - 5:使用 SQL 服务器 LocalDB 创建连接字符串
原文:[译]ASP.NET MVC 5 教程 - 5:使用 SQL 服务器 LocalDB 创建连接字符串 在上一节中,我们创建了MovieDBContext 类来连接数据库.处理Movie 对象和数 ...
- LinQ 创建连接、简单增删改查
LINQ--语言集成查询(Language Integrated Query)是一组用于c#和Visual Basic语言的扩展.它允许编写C#或者Visual Basic代码以查询数据库相同的方式操 ...
随机推荐
- 以http server为例简要分析netty3实现
概要 最近看了点netty3实现.从webbit项目作为口子.webbit项目是一个基于netty3做的http与websocket server.后面还会继续看下netty4,netty4有很多改进 ...
- Vijos1512 SuperBrother打鼹鼠
SuperBrother打鼹鼠 Vijos链接 题目描述: 在一个矩阵中,有三种操作: 1.后面跟着3个数x,y,k,表示在点(x,y)处新出现了k只鼹鼠. 2.后面跟着4个数x1,y1,x2,y2, ...
- 九度oj 题目1527:首尾相连数组的最大子数组和
题目描述: 给定一个由N个整数元素组成的数组arr,数组中有正数也有负数,这个数组不是一般的数组,其首尾是相连的.数组中一个或多个连续元素可以组成一个子数组,其中存在这样的子数组arr[i],…arr ...
- Hibernate框架简述(转)
转自:http://www.cnblogs.com/eflylab/archive/2007/01/09/615338.html Hibernate的核心组件在基于MVC设计模式的JAVA WEB应用 ...
- read(byte[] b)与readFully(byte[] b)
转载于:http://yyzjava.iteye.com/blog/1178525 要搞清楚read(byte[] b)和readFully(byte[] b)的区别,可以从以下方面着手分析: 1.代 ...
- hive查询语法
1.创建表: >create table value_data(citing INT,cited INT) >row format delimited >fields termina ...
- [luoguP2754] 星际转移问题(最大流)
传送门 不同的时间每个飞船所在的地点不同,给我们启示按照时间构建分层图. 同一个地点 x <x, dayi - 1> -> <x, dayi> 连一条容量为 INF 的边 ...
- BZOJ4259 残缺的字符串 【fft】
题目 很久很久以前,在你刚刚学习字符串匹配的时候,有两个仅包含小写字母的字符串A和B,其中A串长度为m,B串长度为n.可当你现在再次碰到这两个串时,这两个串已经老化了,每个串都有不同程度的残缺. 你想 ...
- wireshark推荐书籍
1 wireshark数据包分析实战 有中文版 2 wireshark网络分析 英文版 3 TCP/IP协议栈详解卷一
- scrapy之Selectors
练习url:https://doc.scrapy.org/en/latest/_static/selectors-sample1.html 一 获取文本值 xpath In []: response. ...