Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
ad601a53
提交
ad601a53
authored
12月 08, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
The database upgrade (to upgrade from H2 version 1.1.x) has been simplified.
上级
32b28f61
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
27 行增加
和
15 行删除
+27
-15
Driver.java
h2/src/main/org/h2/Driver.java
+6
-2
ConnectionInfo.java
h2/src/main/org/h2/engine/ConnectionInfo.java
+1
-1
Engine.java
h2/src/main/org/h2/engine/Engine.java
+1
-0
JdbcDataSource.java
h2/src/main/org/h2/jdbcx/JdbcDataSource.java
+4
-2
DbUpgrade.java
h2/src/main/org/h2/upgrade/DbUpgrade.java
+14
-6
TestUpgrade.java
h2/src/test/org/h2/test/db/TestUpgrade.java
+1
-4
没有找到文件。
h2/src/main/org/h2/Driver.java
浏览文件 @
ad601a53
...
...
@@ -6,6 +6,7 @@
*/
package
org
.
h2
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.DriverPropertyInfo
;
import
java.sql.SQLException
;
...
...
@@ -46,7 +47,7 @@ public class Driver implements java.sql.Driver {
* @param info the connection properties
* @return the new connection or null if the URL is not supported
*/
public
Jdbc
Connection
connect
(
String
url
,
Properties
info
)
throws
SQLException
{
public
Connection
connect
(
String
url
,
Properties
info
)
throws
SQLException
{
try
{
if
(
info
==
null
)
{
info
=
new
Properties
();
...
...
@@ -54,7 +55,10 @@ public class Driver implements java.sql.Driver {
if
(!
acceptsURL
(
url
))
{
return
null
;
}
DbUpgrade
.
upgradeIfRequired
(
url
,
info
);
Connection
c
=
DbUpgrade
.
connctOrUpgrade
(
url
,
info
);
if
(
c
!=
null
)
{
return
c
;
}
return
new
JdbcConnection
(
url
,
info
);
}
catch
(
Exception
e
)
{
throw
DbException
.
toSQLException
(
e
);
...
...
h2/src/main/org/h2/engine/ConnectionInfo.java
浏览文件 @
ad601a53
...
...
@@ -83,7 +83,7 @@ public class ConnectionInfo implements Cloneable {
set
.
addAll
(
list
);
String
[]
connectionTime
=
{
"ACCESS_MODE_DATA"
,
"AUTOCOMMIT"
,
"CIPHER"
,
"CREATE"
,
"CACHE_TYPE"
,
"FILE_LOCK"
,
"IGNORE_UNKNOWN_SETTINGS"
,
"IFEXISTS"
,
"INIT"
,
"PASSWORD"
,
"RECOVER"
,
"USER"
,
"AUTO_SERVER"
,
"INIT"
,
"PASSWORD"
,
"RECOVER"
,
"USER"
,
"AUTO_SERVER"
,
"NO_UPGRADE"
,
"AUTO_RECONNECT"
,
"OPEN_NEW"
,
"PAGE_SIZE"
,
"PASSWORD_HASH"
,
"JMX"
};
for
(
String
key
:
connectionTime
)
{
if
(
SysProperties
.
CHECK
&&
set
.
contains
(
key
))
{
...
...
h2/src/main/org/h2/engine/Engine.java
浏览文件 @
ad601a53
...
...
@@ -40,6 +40,7 @@ public class Engine implements SessionFactory {
private
Session
openSession
(
ConnectionInfo
ci
,
boolean
ifExists
,
String
cipher
)
{
String
name
=
ci
.
getName
();
Database
database
;
ci
.
removeProperty
(
"NO_UPGRADE"
,
false
);
boolean
openNew
=
ci
.
getProperty
(
"OPEN_NEW"
,
false
);
if
(
openNew
||
ci
.
isUnnamedInMemory
())
{
database
=
null
;
...
...
h2/src/main/org/h2/jdbcx/JdbcDataSource.java
浏览文件 @
ad601a53
...
...
@@ -177,11 +177,13 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
Properties
info
=
new
Properties
();
info
.
setProperty
(
"user"
,
user
);
info
.
put
(
"password"
,
password
);
Jdbc
Connection
conn
=
Driver
.
load
().
connect
(
url
,
info
);
Connection
conn
=
Driver
.
load
().
connect
(
url
,
info
);
if
(
conn
==
null
)
{
throw
new
SQLException
(
"No suitable driver found for "
+
url
,
"08001"
,
8001
);
}
else
if
(!(
conn
instanceof
JdbcConnection
))
{
throw
new
SQLException
(
"Connecting with old version is not supported: "
+
url
,
"08001"
,
8001
);
}
return
conn
;
return
(
JdbcConnection
)
conn
;
}
/**
...
...
h2/src/main/org/h2/upgrade/DbUpgrade.java
浏览文件 @
ad601a53
...
...
@@ -45,9 +45,9 @@ public class DbUpgrade {
* @param url the database URL
* @param info the properties
*/
public
static
void
upgradeIfRequired
(
String
url
,
Properties
info
)
throws
SQLException
{
public
static
Connection
connctOrUpgrade
(
String
url
,
Properties
info
)
throws
SQLException
{
if
(!
upgradeClassesPresent
)
{
return
;
return
null
;
}
Properties
i2
=
new
Properties
();
i2
.
putAll
(
info
);
...
...
@@ -59,18 +59,21 @@ public class DbUpgrade {
info
=
i2
;
ConnectionInfo
ci
=
new
ConnectionInfo
(
url
,
info
);
if
(
ci
.
isRemote
()
||
!
ci
.
isPersistent
())
{
return
;
return
null
;
}
String
name
=
ci
.
getName
();
if
(
Database
.
exists
(
name
))
{
return
;
return
null
;
}
if
(!
IOUtils
.
exists
(
name
+
".data.db"
))
{
return
;
return
null
;
}
if
(
ci
.
removeProperty
(
"NO_UPGRADE"
,
false
))
{
return
connectWithOldVersion
(
url
,
info
);
}
synchronized
(
DbUpgrade
.
class
)
{
upgrade
(
ci
,
info
);
return
;
return
null
;
}
}
...
...
@@ -97,6 +100,11 @@ public class DbUpgrade {
DbUpgrade
.
deleteOldDb
=
deleteOldDb
;
}
private
static
Connection
connectWithOldVersion
(
String
url
,
Properties
info
)
throws
SQLException
{
url
=
"jdbc:h2v1_1:"
+
url
.
substring
(
"jdbc:h2:"
.
length
())
+
";IGNORE_UNKNOWN_SETTINGS=TRUE"
;
return
DriverManager
.
getConnection
(
url
,
info
);
}
private
static
void
upgrade
(
ConnectionInfo
ci
,
Properties
info
)
throws
SQLException
{
String
name
=
ci
.
getName
();
String
data
=
name
+
".data.db"
;
...
...
h2/src/test/org/h2/test/db/TestUpgrade.java
浏览文件 @
ad601a53
...
...
@@ -93,10 +93,7 @@ public class TestUpgrade extends TestBase {
assertTrue
(
IOUtils
.
exists
(
getBaseDir
()
+
"/upgrade.h2.db"
));
deleteDb
(
"upgrade"
);
conn
=
getConnection
(
"jdbc:h2v1_1:"
+
getBaseDir
()
+
"/upgrade"
);
conn
.
close
();
conn
=
getConnection
(
"upgrade"
);
conn
=
getConnection
(
"upgrade;NO_UPGRADE=TRUE"
);
conn
.
close
();
assertTrue
(
IOUtils
.
exists
(
getBaseDir
()
+
"/upgrade.h2.db"
));
deleteDb
(
"upgrade"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论