Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3523c1df
提交
3523c1df
authored
12月 04, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve code coverage.
上级
d526e92a
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
37 行增加
和
34 行删除
+37
-34
Driver.java
h2/src/main/org/h2/Driver.java
+3
-13
DbUpgrade.java
h2/src/main/org/h2/upgrade/DbUpgrade.java
+30
-21
Build.java
h2/src/tools/org/h2/build/Build.java
+4
-0
没有找到文件。
h2/src/main/org/h2/Driver.java
浏览文件 @
3523c1df
...
...
@@ -11,13 +11,11 @@ import java.sql.DriverManager;
import
java.sql.DriverPropertyInfo
;
import
java.sql.SQLException
;
import
java.util.Properties
;
import
org.h2.engine.Constants
;
import
org.h2.jdbc.JdbcConnection
;
import
org.h2.message.DbException
;
import
org.h2.message.TraceSystem
;
import
org.h2.upgrade.DbUpgrade
;
import
org.h2.util.StringUtils
;
/**
* The database driver. An application should not use this class directly. The
...
...
@@ -57,17 +55,9 @@ public class Driver implements java.sql.Driver {
if
(!
acceptsURL
(
url
))
{
return
null
;
}
boolean
noUpgrade
=
StringUtils
.
toUpperEnglish
(
url
).
indexOf
(
";NO_UPGRADE=TRUE"
)
>=
0
;
url
=
StringUtils
.
replaceAllIgnoreCase
(
url
,
";NO_UPGRADE=TRUE"
,
""
);
if
(
DbUpgrade
.
areUpgradeClassesPresent
())
{
if
(
noUpgrade
)
{
Connection
connection
=
DbUpgrade
.
connectWithOldVersion
(
url
,
info
);
if
(
connection
!=
null
)
{
return
connection
;
}
}
else
{
DbUpgrade
.
upgrade
(
url
,
info
);
}
Connection
conn
=
DbUpgrade
.
connectOrUpgrade
(
url
,
info
);
if
(
conn
!=
null
)
{
return
conn
;
}
return
new
JdbcConnection
(
url
,
info
);
}
catch
(
Exception
e
)
{
...
...
h2/src/main/org/h2/upgrade/DbUpgrade.java
浏览文件 @
3523c1df
...
...
@@ -27,22 +27,33 @@ import org.h2.util.Utils;
public
class
DbUpgrade
{
private
static
boolean
upgradeClassesPresent
;
private
static
Map
<
String
,
DbUpgradeFromVersion1
>
runningConversions
;
static
{
// static initialize block
upgradeClassesPresent
=
Utils
.
isClassPresent
(
"org.h2.upgrade.v1_1.Driver"
);
runningConversions
=
Collections
.
synchronizedMap
(
new
Hashtable
<
String
,
DbUpgradeFromVersion1
>(
1
));
}
/**
* Check if the H2 version 1.1 driver is in in the classpath.
* If the upgrade classes are present, upgrade the database, or connect
* using the old version (if the parameter NO_UPGRADE is set to true). If
* the database is upgraded, or if no upgrade is possible or needed, this
* methods returns null.
*
* @return true if it is
* @param url the database URL
* @param info the properties
* @return the connection if NO_UPGRADE is set
*/
public
static
boolean
areUpgradeClassesPresent
()
{
return
upgradeClassesPresent
;
public
static
synchronized
Connection
connectOrUpgrade
(
String
url
,
Properties
info
)
throws
SQLException
{
if
(!
upgradeClassesPresent
)
{
return
null
;
}
if
(
StringUtils
.
toUpperEnglish
(
url
).
indexOf
(
";NO_UPGRADE=TRUE"
)
>=
0
)
{
url
=
StringUtils
.
replaceAllIgnoreCase
(
url
,
";NO_UPGRADE=TRUE"
,
""
);
return
connectWithOldVersion
(
url
,
info
);
}
upgrade
(
url
,
info
);
return
null
;
}
/**
...
...
@@ -53,7 +64,7 @@ public class DbUpgrade {
* @return the connection via the upgrade classes
* @throws SQLException
*/
p
ublic
static
Connection
connectWithOldVersion
(
String
url
,
Properties
info
)
throws
SQLException
{
p
rivate
static
Connection
connectWithOldVersion
(
String
url
,
Properties
info
)
throws
SQLException
{
try
{
String
oldStartUrlPrefix
=
(
String
)
Utils
.
getStaticField
(
"org.h2.upgrade.v1_1.engine.Constants.START_URL"
);
url
=
StringUtils
.
replaceAll
(
url
,
org
.
h2
.
engine
.
Constants
.
START_URL
,
oldStartUrlPrefix
);
...
...
@@ -97,8 +108,7 @@ public class DbUpgrade {
* @param info The connection properties
* @throws SQLException
*/
public
static
synchronized
void
upgrade
(
String
url
,
Properties
info
)
throws
SQLException
{
if
(
upgradeClassesPresent
)
{
private
static
synchronized
void
upgrade
(
String
url
,
Properties
info
)
throws
SQLException
{
if
(
runningConversions
.
containsKey
(
url
))
{
// do not migrate, because we are currently migrating, and this is
// the connection where "runscript from" will be executed
...
...
@@ -112,6 +122,5 @@ public class DbUpgrade {
runningConversions
.
remove
(
url
);
}
}
}
}
h2/src/tools/org/h2/build/Build.java
浏览文件 @
3523c1df
...
...
@@ -243,6 +243,10 @@ public class Build extends BuildBase {
}
private
void
downloadTest
()
{
// for TestUpgrade
download
(
"ext/h2mig_pagestore_addon.jar"
,
"http://h2database.com/h2mig_pagestore_addon.jar"
,
"6dfafe1b86959c3ba4f7cf03e99535e8b9719965"
);
// for TestOldVersion
download
(
"ext/h2-1.2.127.jar"
,
"http://repo1.maven.org/maven2/com/h2database/h2/1.2.127/h2-1.2.127.jar"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论