Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
2585b4ea
提交
2585b4ea
authored
11月 20, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Various smaller changes (FindBugs)
上级
8b1510e3
隐藏空白字符变更
内嵌
并排
正在显示
54 个修改的文件
包含
181 行增加
和
89 行删除
+181
-89
CreateView.java
h2/src/main/org/h2/command/ddl/CreateView.java
+1
-1
Constants.java
h2/src/main/org/h2/engine/Constants.java
+1
-1
Function.java
h2/src/main/org/h2/expression/Function.java
+4
-8
JdbcConnection.java
h2/src/main/org/h2/jdbc/JdbcConnection.java
+1
-1
DbStarter.java
h2/src/main/org/h2/server/web/DbStarter.java
+4
-1
FileLock.java
h2/src/main/org/h2/store/FileLock.java
+1
-1
LobStorage.java
h2/src/main/org/h2/store/LobStorage.java
+2
-5
Page.java
h2/src/main/org/h2/store/Page.java
+3
-4
PageStreamTrunk.java
h2/src/main/org/h2/store/PageStreamTrunk.java
+1
-1
CreateCluster.java
h2/src/main/org/h2/tools/CreateCluster.java
+3
-1
Recover.java
h2/src/main/org/h2/tools/Recover.java
+1
-1
MathUtils.java
h2/src/main/org/h2/util/MathUtils.java
+1
-0
Compact.java
h2/src/test/org/h2/samples/Compact.java
+1
-0
DirectInsert.java
h2/src/test/org/h2/samples/DirectInsert.java
+3
-0
FileFunctions.java
h2/src/test/org/h2/samples/FileFunctions.java
+1
-0
Function.java
h2/src/test/org/h2/samples/Function.java
+6
-5
FunctionMultiReturn.java
h2/src/test/org/h2/samples/FunctionMultiReturn.java
+3
-1
HelloWorld.java
h2/src/test/org/h2/samples/HelloWorld.java
+1
-0
InitDatabaseFromJar.java
h2/src/test/org/h2/samples/InitDatabaseFromJar.java
+5
-1
SQLInjection.java
h2/src/test/org/h2/samples/SQLInjection.java
+11
-0
SecurePassword.java
h2/src/test/org/h2/samples/SecurePassword.java
+7
-0
ShowProgress.java
h2/src/test/org/h2/samples/ShowProgress.java
+2
-0
TriggerPassData.java
h2/src/test/org/h2/samples/TriggerPassData.java
+1
-0
TriggerSample.java
h2/src/test/org/h2/samples/TriggerSample.java
+2
-0
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+1
-3
Database.java
h2/src/test/org/h2/test/bench/Database.java
+1
-1
TestCluster.java
h2/src/test/org/h2/test/db/TestCluster.java
+1
-1
TestFullText.java
h2/src/test/org/h2/test/db/TestFullText.java
+1
-1
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+2
-2
TestOptimizations.java
h2/src/test/org/h2/test/db/TestOptimizations.java
+2
-2
TestQueryCache.java
h2/src/test/org/h2/test/db/TestQueryCache.java
+3
-2
TestRecursiveQueries.java
h2/src/test/org/h2/test/db/TestRecursiveQueries.java
+1
-1
TestRights.java
h2/src/test/org/h2/test/db/TestRights.java
+2
-2
TestTransaction.java
h2/src/test/org/h2/test/db/TestTransaction.java
+0
-2
UpdateTest.java
h2/src/test/org/h2/test/jaqu/UpdateTest.java
+2
-2
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+6
-6
TestResultSet.java
h2/src/test/org/h2/test/jdbc/TestResultSet.java
+2
-1
TestUpdatableResultSet.java
h2/src/test/org/h2/test/jdbc/TestUpdatableResultSet.java
+1
-1
TestCrashAPI.java
h2/src/test/org/h2/test/synth/TestCrashAPI.java
+7
-6
TestJoin.java
h2/src/test/org/h2/test/synth/TestJoin.java
+1
-1
Value.java
h2/src/test/org/h2/test/synth/sql/Value.java
+6
-6
test-1.3.txt
h2/src/test/org/h2/test/test-1.3.txt
+57
-0
Parser.java
h2/src/test/org/h2/test/trace/Parser.java
+5
-5
Player.java
h2/src/test/org/h2/test/trace/Player.java
+1
-0
TestCache.java
h2/src/test/org/h2/test/unit/TestCache.java
+1
-1
TestJmx.java
h2/src/test/org/h2/test/unit/TestJmx.java
+0
-1
TestNetUtils.java
h2/src/test/org/h2/test/unit/TestNetUtils.java
+1
-1
TestOldVersion.java
h2/src/test/org/h2/test/unit/TestOldVersion.java
+1
-1
TestPageStore.java
h2/src/test/org/h2/test/unit/TestPageStore.java
+1
-1
TestPageStoreCoverage.java
h2/src/test/org/h2/test/unit/TestPageStoreCoverage.java
+1
-0
TestReopen.java
h2/src/test/org/h2/test/unit/TestReopen.java
+2
-1
TestTools.java
h2/src/test/org/h2/test/unit/TestTools.java
+2
-2
BuildBase.java
h2/src/tools/org/h2/build/BuildBase.java
+3
-3
Function.java
h2/src/tools/org/h2/jaqu/Function.java
+1
-1
没有找到文件。
h2/src/main/org/h2/command/ddl/CreateView.java
浏览文件 @
2585b4ea
...
@@ -177,7 +177,7 @@ public class CreateView extends SchemaCommand {
...
@@ -177,7 +177,7 @@ public class CreateView extends SchemaCommand {
* work with TableViews directly because they become invalid when we drop
* work with TableViews directly because they become invalid when we drop
* the parent view.
* the parent view.
*/
*/
private
class
DependentView
{
private
static
class
DependentView
{
String
viewName
;
String
viewName
;
String
createSql
;
String
createSql
;
String
createForceSql
;
String
createForceSql
;
...
...
h2/src/main/org/h2/engine/Constants.java
浏览文件 @
2585b4ea
...
@@ -64,7 +64,7 @@ public class Constants {
...
@@ -64,7 +64,7 @@ public class Constants {
/**
/**
* The minor version of this database.
* The minor version of this database.
*/
*/
public
static
final
int
VERSION_MINOR
=
3
;
public
static
final
int
VERSION_MINOR
=
2
;
// Build.getLuceneVersion() uses an ugly hack to read this value
// Build.getLuceneVersion() uses an ugly hack to read this value
/**
/**
...
...
h2/src/main/org/h2/expression/Function.java
浏览文件 @
2585b4ea
...
@@ -102,8 +102,6 @@ public class Function extends Expression implements FunctionCall {
...
@@ -102,8 +102,6 @@ public class Function extends Expression implements FunctionCall {
private
static
final
HashMap
<
String
,
FunctionInfo
>
FUNCTIONS
=
New
.
hashMap
();
private
static
final
HashMap
<
String
,
FunctionInfo
>
FUNCTIONS
=
New
.
hashMap
();
private
static
final
HashMap
<
String
,
Integer
>
DATE_PART
=
New
.
hashMap
();
private
static
final
HashMap
<
String
,
Integer
>
DATE_PART
=
New
.
hashMap
();
private
static
final
SimpleDateFormat
FORMAT_DAYNAME
=
new
SimpleDateFormat
(
"EEEE"
,
Locale
.
ENGLISH
);
private
static
final
SimpleDateFormat
FORMAT_MONTHNAME
=
new
SimpleDateFormat
(
"MMMM"
,
Locale
.
ENGLISH
);
private
static
final
char
[]
SOUNDEX_INDEX
=
new
char
[
128
];
private
static
final
char
[]
SOUNDEX_INDEX
=
new
char
[
128
];
protected
Expression
[]
args
;
protected
Expression
[]
args
;
...
@@ -605,9 +603,8 @@ public class Function extends Expression implements FunctionCall {
...
@@ -605,9 +603,8 @@ public class Function extends Expression implements FunctionCall {
result
=
ValueString
.
get
(
StringUtils
.
xmlText
(
v0
.
getString
()));
result
=
ValueString
.
get
(
StringUtils
.
xmlText
(
v0
.
getString
()));
break
;
break
;
case
DAY_NAME:
{
case
DAY_NAME:
{
synchronized
(
FORMAT_DAYNAME
)
{
SimpleDateFormat
dayName
=
new
SimpleDateFormat
(
"EEEE"
,
Locale
.
ENGLISH
);
result
=
ValueString
.
get
(
FORMAT_DAYNAME
.
format
(
v0
.
getDateNoCopy
()));
result
=
ValueString
.
get
(
dayName
.
format
(
v0
.
getDateNoCopy
()));
}
break
;
break
;
}
}
case
DAY_OF_MONTH:
case
DAY_OF_MONTH:
...
@@ -629,9 +626,8 @@ public class Function extends Expression implements FunctionCall {
...
@@ -629,9 +626,8 @@ public class Function extends Expression implements FunctionCall {
result
=
ValueInt
.
get
(
DateTimeUtils
.
getDatePart
(
v0
.
getDateNoCopy
(),
Calendar
.
MONTH
));
result
=
ValueInt
.
get
(
DateTimeUtils
.
getDatePart
(
v0
.
getDateNoCopy
(),
Calendar
.
MONTH
));
break
;
break
;
case
MONTH_NAME:
{
case
MONTH_NAME:
{
synchronized
(
FORMAT_MONTHNAME
)
{
SimpleDateFormat
monthName
=
new
SimpleDateFormat
(
"MMMM"
,
Locale
.
ENGLISH
);
result
=
ValueString
.
get
(
FORMAT_MONTHNAME
.
format
(
v0
.
getDateNoCopy
()));
result
=
ValueString
.
get
(
monthName
.
format
(
v0
.
getDateNoCopy
()));
}
break
;
break
;
}
}
case
QUARTER:
case
QUARTER:
...
...
h2/src/main/org/h2/jdbc/JdbcConnection.java
浏览文件 @
2585b4ea
...
@@ -1142,7 +1142,7 @@ public class JdbcConnection extends TraceObject implements Connection {
...
@@ -1142,7 +1142,7 @@ public class JdbcConnection extends TraceObject implements Connection {
*/
*/
String
translateSQL
(
String
sql
,
boolean
escapeProcessing
)
{
String
translateSQL
(
String
sql
,
boolean
escapeProcessing
)
{
if
(
sql
==
null
)
{
if
(
sql
==
null
)
{
throw
DbException
.
getInvalidValueException
(
"SQL"
,
sq
l
);
throw
DbException
.
getInvalidValueException
(
"SQL"
,
nul
l
);
}
}
if
(!
escapeProcessing
)
{
if
(!
escapeProcessing
)
{
return
sql
;
return
sql
;
...
...
h2/src/main/org/h2/server/web/DbStarter.java
浏览文件 @
2585b4ea
...
@@ -8,6 +8,7 @@ package org.h2.server.web;
...
@@ -8,6 +8,7 @@ package org.h2.server.web;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.DriverManager
;
import
java.sql.Statement
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletContextEvent
;
import
javax.servlet.ServletContextEvent
;
...
@@ -70,7 +71,9 @@ public class DbStarter implements ServletContextListener {
...
@@ -70,7 +71,9 @@ public class DbStarter implements ServletContextListener {
public
void
contextDestroyed
(
ServletContextEvent
servletContextEvent
)
{
public
void
contextDestroyed
(
ServletContextEvent
servletContextEvent
)
{
try
{
try
{
conn
.
createStatement
().
execute
(
"SHUTDOWN"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"SHUTDOWN"
);
stat
.
close
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
h2/src/main/org/h2/store/FileLock.java
浏览文件 @
2585b4ea
...
@@ -276,7 +276,7 @@ public class FileLock implements Runnable {
...
@@ -276,7 +276,7 @@ public class FileLock implements Runnable {
// lock file modified in the future -
// lock file modified in the future -
// wait for a bit longer than usual
// wait for a bit longer than usual
try
{
try
{
Thread
.
sleep
(
2
*
sleep
);
Thread
.
sleep
(
2
*
(
long
)
sleep
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
trace
.
debug
(
e
,
"sleep"
);
trace
.
debug
(
e
,
"sleep"
);
}
}
...
...
h2/src/main/org/h2/store/LobStorage.java
浏览文件 @
2585b4ea
...
@@ -100,6 +100,7 @@ public class LobStorage {
...
@@ -100,6 +100,7 @@ public class LobStorage {
rs
=
stat
.
executeQuery
(
"SELECT MAX(BLOCK) FROM "
+
LOB_DATA
);
rs
=
stat
.
executeQuery
(
"SELECT MAX(BLOCK) FROM "
+
LOB_DATA
);
rs
.
next
();
rs
.
next
();
nextBlock
=
rs
.
getLong
(
1
)
+
1
;
nextBlock
=
rs
.
getLong
(
1
)
+
1
;
stat
.
close
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
throw
DbException
.
convert
(
e
);
throw
DbException
.
convert
(
e
);
}
}
...
@@ -602,11 +603,7 @@ public class LobStorage {
...
@@ -602,11 +603,7 @@ public class LobStorage {
PreparedStatement
prep
=
prepare
(
"UPDATE "
+
LOBS
+
" SET TABLE = ? WHERE ID = ?"
);
PreparedStatement
prep
=
prepare
(
"UPDATE "
+
LOBS
+
" SET TABLE = ? WHERE ID = ?"
);
prep
.
setInt
(
1
,
table
);
prep
.
setInt
(
1
,
table
);
prep
.
setLong
(
2
,
lobId
);
prep
.
setLong
(
2
,
lobId
);
int
updateCount
=
prep
.
executeUpdate
();
prep
.
executeUpdate
();
if
(
updateCount
!=
1
)
{
// can be zero when recovering
// throw DbException.throwInternalError("count: " + updateCount);
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
throw
DbException
.
convert
(
e
);
throw
DbException
.
convert
(
e
);
}
}
...
...
h2/src/main/org/h2/store/Page.java
浏览文件 @
2585b4ea
...
@@ -100,10 +100,9 @@ public abstract class Page extends CacheObject {
...
@@ -100,10 +100,9 @@ public abstract class Page extends CacheObject {
* @return the (new) array
* @return the (new) array
*/
*/
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
public
public
static
<
T
>
T
[]
insert
(
T
[]
old
,
int
oldSize
,
int
pos
,
T
x
)
{
static
<
T
>
T
[]
insert
(
T
[]
old
,
int
oldSize
,
int
pos
,
T
x
)
{
T
[]
result
;
T
[]
result
;
if
(
old
!=
null
&&
old
.
length
>
oldSize
)
{
if
(
old
.
length
>
oldSize
)
{
result
=
old
;
result
=
old
;
}
else
{
}
else
{
// according to a test, this is as fast as "new Row[..]"
// according to a test, this is as fast as "new Row[..]"
...
@@ -112,7 +111,7 @@ public abstract class Page extends CacheObject {
...
@@ -112,7 +111,7 @@ public abstract class Page extends CacheObject {
System
.
arraycopy
(
old
,
0
,
result
,
0
,
pos
);
System
.
arraycopy
(
old
,
0
,
result
,
0
,
pos
);
}
}
}
}
if
(
old
!=
null
&&
old
Size
-
pos
>
0
)
{
if
(
oldSize
-
pos
>
0
)
{
System
.
arraycopy
(
old
,
pos
,
result
,
pos
+
1
,
oldSize
-
pos
);
System
.
arraycopy
(
old
,
pos
,
result
,
pos
+
1
,
oldSize
-
pos
);
}
}
result
[
pos
]
=
x
;
result
[
pos
]
=
x
;
...
...
h2/src/main/org/h2/store/PageStreamTrunk.java
浏览文件 @
2585b4ea
...
@@ -115,7 +115,7 @@ public class PageStreamTrunk extends Page {
...
@@ -115,7 +115,7 @@ public class PageStreamTrunk extends Page {
if
(
index
>=
pageIds
.
length
)
{
if
(
index
>=
pageIds
.
length
)
{
return
-
1
;
return
-
1
;
}
}
return
pageIds
[
index
++
];
return
pageIds
[
index
];
}
}
public
void
write
()
{
public
void
write
()
{
...
...
h2/src/main/org/h2/tools/CreateCluster.java
浏览文件 @
2585b4ea
...
@@ -107,7 +107,9 @@ public class CreateCluster extends Tool {
...
@@ -107,7 +107,9 @@ public class CreateCluster extends Tool {
boolean
exists
=
true
;
boolean
exists
=
true
;
try
{
try
{
connTarget
=
DriverManager
.
getConnection
(
urlTarget
+
";IFEXISTS=TRUE;CLUSTER="
+
Constants
.
CLUSTERING_ENABLED
,
user
,
password
);
connTarget
=
DriverManager
.
getConnection
(
urlTarget
+
";IFEXISTS=TRUE;CLUSTER="
+
Constants
.
CLUSTERING_ENABLED
,
user
,
password
);
connTarget
.
createStatement
().
execute
(
"DROP ALL OBJECTS DELETE FILES"
);
Statement
stat
=
connTarget
.
createStatement
();
stat
.
execute
(
"DROP ALL OBJECTS DELETE FILES"
);
stat
.
close
();
exists
=
false
;
exists
=
false
;
connTarget
.
close
();
connTarget
.
close
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
...
...
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
2585b4ea
...
@@ -86,7 +86,7 @@ public class Recover extends Tool implements DataHandler {
...
@@ -86,7 +86,7 @@ public class Recover extends Tool implements DataHandler {
/**
/**
* Statistic data
* Statistic data
*/
*/
class
Stats
{
static
class
Stats
{
/**
/**
* The empty space in bytes in a data leaf pages.
* The empty space in bytes in a data leaf pages.
...
...
h2/src/main/org/h2/util/MathUtils.java
浏览文件 @
2585b4ea
...
@@ -123,6 +123,7 @@ public class MathUtils {
...
@@ -123,6 +123,7 @@ public class MathUtils {
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
// nanoTime not found, this is ok (only exists for JDK 1.5 and higher)
// nanoTime not found, this is ok (only exists for JDK 1.5 and higher)
out
.
writeUTF
(
e
.
toString
());
}
}
// memory
// memory
...
...
h2/src/test/org/h2/samples/Compact.java
浏览文件 @
2585b4ea
...
@@ -36,6 +36,7 @@ public class Compact {
...
@@ -36,6 +36,7 @@ public class Compact {
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(1, 'Hello'), (2, 'World');"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(1, 'Hello'), (2, 'World');"
);
stat
.
close
();
conn
.
close
();
conn
.
close
();
System
.
out
.
println
(
"Compacting..."
);
System
.
out
.
println
(
"Compacting..."
);
compact
(
"data"
,
"test"
,
"sa"
,
""
);
compact
(
"data"
,
"test"
,
"sa"
,
""
);
...
...
h2/src/test/org/h2/samples/DirectInsert.java
浏览文件 @
2585b4ea
...
@@ -53,6 +53,8 @@ public class DirectInsert {
...
@@ -53,6 +53,8 @@ public class DirectInsert {
prep
.
execute
();
prep
.
execute
();
}
}
conn
.
commit
();
conn
.
commit
();
prep
.
close
();
stat
.
close
();
conn
.
close
();
conn
.
close
();
}
}
...
@@ -65,6 +67,7 @@ public class DirectInsert {
...
@@ -65,6 +67,7 @@ public class DirectInsert {
stat
.
execute
(
"CREATE TABLE TEST2 AS SELECT * FROM TEST"
);
stat
.
execute
(
"CREATE TABLE TEST2 AS SELECT * FROM TEST"
);
System
.
out
.
printf
(
"%.3f sec.\n"
,
(
System
.
currentTimeMillis
()
-
time
)
/
1000.0
);
System
.
out
.
printf
(
"%.3f sec.\n"
,
(
System
.
currentTimeMillis
()
-
time
)
/
1000.0
);
stat
.
execute
(
"INSERT INTO TEST2 SELECT * FROM TEST2"
);
stat
.
execute
(
"INSERT INTO TEST2 SELECT * FROM TEST2"
);
stat
.
close
();
conn
.
close
();
conn
.
close
();
}
}
...
...
h2/src/test/org/h2/samples/FileFunctions.java
浏览文件 @
2585b4ea
...
@@ -40,6 +40,7 @@ public class FileFunctions {
...
@@ -40,6 +40,7 @@ public class FileFunctions {
rs
.
next
();
rs
.
next
();
String
text
=
rs
.
getString
(
1
);
String
text
=
rs
.
getString
(
1
);
System
.
out
.
println
(
"text: "
+
text
);
System
.
out
.
println
(
"text: "
+
text
);
stat
.
close
();
conn
.
close
();
conn
.
close
();
}
}
...
...
h2/src/test/org/h2/samples/Function.java
浏览文件 @
2585b4ea
...
@@ -51,14 +51,14 @@ public class Function {
...
@@ -51,14 +51,14 @@ public class Function {
PreparedStatement
prep
;
PreparedStatement
prep
;
prep
=
conn
.
prepareStatement
(
"SELECT * FROM TABLE(X INT=?, O INT=?) J "
+
prep
=
conn
.
prepareStatement
(
"SELECT * FROM TABLE(X INT=?, O INT=?) J "
+
"INNER JOIN TEST T ON J.X=T.ID ORDER BY J.O"
);
"INNER JOIN TEST T ON J.X=T.ID ORDER BY J.O"
);
prep
.
setObject
(
1
,
prep
.
setObject
(
1
,
new
Integer
[]
{
30
,
20
});
new
Integer
[]
{
new
Integer
(
30
),
new
Integer
(
20
)
});
prep
.
setObject
(
2
,
new
Integer
[]
{
1
,
2
});
prep
.
setObject
(
2
,
new
Integer
[]
{
new
Integer
(
1
),
new
Integer
(
2
)
});
rs
=
prep
.
executeQuery
();
rs
=
prep
.
executeQuery
();
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
System
.
out
.
println
(
rs
.
getInt
(
1
));
System
.
out
.
println
(
rs
.
getInt
(
1
));
}
}
prep
.
close
();
rs
.
close
();
// Using a custom function like table
// Using a custom function like table
stat
.
execute
(
"CREATE ALIAS MATRIX FOR \"org.h2.samples.Function.getMatrix\" "
);
stat
.
execute
(
"CREATE ALIAS MATRIX FOR \"org.h2.samples.Function.getMatrix\" "
);
...
@@ -69,7 +69,8 @@ public class Function {
...
@@ -69,7 +69,8 @@ public class Function {
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
System
.
out
.
println
(
rs
.
getInt
(
1
)
+
"/"
+
rs
.
getInt
(
2
));
System
.
out
.
println
(
rs
.
getInt
(
1
)
+
"/"
+
rs
.
getInt
(
2
));
}
}
prep
.
close
();
stat
.
close
();
conn
.
close
();
conn
.
close
();
}
}
...
...
h2/src/test/org/h2/samples/FunctionMultiReturn.java
浏览文件 @
2585b4ea
...
@@ -69,7 +69,7 @@ public class FunctionMultiReturn {
...
@@ -69,7 +69,7 @@ public class FunctionMultiReturn {
System
.
out
.
println
(
"(r="
+
r
+
" a="
+
a
+
") : (x="
+
x
+
", y="
+
y
+
")"
);
System
.
out
.
println
(
"(r="
+
r
+
" a="
+
a
+
") : (x="
+
x
+
", y="
+
y
+
")"
);
}
}
rs
=
conn
.
createStatement
()
.
executeQuery
(
"SELECT R, A, ARRAY_GET(E, 1), ARRAY_GET(E, 2) FROM (SELECT R, A, P2C_A(R, A) E FROM TEST)"
);
rs
=
stat
.
executeQuery
(
"SELECT R, A, ARRAY_GET(E, 1), ARRAY_GET(E, 2) FROM (SELECT R, A, P2C_A(R, A) E FROM TEST)"
);
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
double
r
=
rs
.
getDouble
(
1
);
double
r
=
rs
.
getDouble
(
1
);
double
a
=
rs
.
getDouble
(
2
);
double
a
=
rs
.
getDouble
(
2
);
...
@@ -77,7 +77,9 @@ public class FunctionMultiReturn {
...
@@ -77,7 +77,9 @@ public class FunctionMultiReturn {
double
y
=
rs
.
getDouble
(
4
);
double
y
=
rs
.
getDouble
(
4
);
System
.
out
.
println
(
"(r="
+
r
+
" a="
+
a
+
") : (x="
+
x
+
", y="
+
y
+
")"
);
System
.
out
.
println
(
"(r="
+
r
+
" a="
+
a
+
") : (x="
+
x
+
", y="
+
y
+
")"
);
}
}
rs
.
close
();
prep
.
close
();
conn
.
close
();
conn
.
close
();
}
}
...
...
h2/src/test/org/h2/samples/HelloWorld.java
浏览文件 @
2585b4ea
...
@@ -41,6 +41,7 @@ public class HelloWorld {
...
@@ -41,6 +41,7 @@ public class HelloWorld {
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
System
.
out
.
println
(
rs
.
getString
(
"name"
));
System
.
out
.
println
(
rs
.
getString
(
"name"
));
}
}
stat
.
close
();
conn
.
close
();
conn
.
close
();
}
}
...
...
h2/src/test/org/h2/samples/InitDatabaseFromJar.java
浏览文件 @
2585b4ea
...
@@ -42,6 +42,7 @@ public class InitDatabaseFromJar {
...
@@ -42,6 +42,7 @@ public class InitDatabaseFromJar {
stat
.
execute
(
"CREATE TABLE TEST(NAME VARCHAR)"
);
stat
.
execute
(
"CREATE TABLE TEST(NAME VARCHAR)"
);
stat
.
execute
(
"INSERT INTO TEST VALUES('Hello World')"
);
stat
.
execute
(
"INSERT INTO TEST VALUES('Hello World')"
);
stat
.
execute
(
"SCRIPT TO 'script.sql'"
);
stat
.
execute
(
"SCRIPT TO 'script.sql'"
);
stat
.
close
();
conn
.
close
();
conn
.
close
();
}
}
...
@@ -57,10 +58,13 @@ public class InitDatabaseFromJar {
...
@@ -57,10 +58,13 @@ public class InitDatabaseFromJar {
+
getClass
().
getPackage
().
getName
());
+
getClass
().
getPackage
().
getName
());
}
else
{
}
else
{
RunScript
.
execute
(
conn
,
new
InputStreamReader
(
in
));
RunScript
.
execute
(
conn
,
new
InputStreamReader
(
in
));
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM TEST"
);
Statement
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST"
);
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
System
.
out
.
println
(
rs
.
getString
(
1
));
System
.
out
.
println
(
rs
.
getString
(
1
));
}
}
rs
.
close
();
stat
.
close
();
conn
.
close
();
conn
.
close
();
}
}
}
}
...
...
h2/src/test/org/h2/samples/SQLInjection.java
浏览文件 @
2585b4ea
...
@@ -212,6 +212,8 @@ public class SQLInjection {
...
@@ -212,6 +212,8 @@ public class SQLInjection {
}
else
{
}
else
{
System
.
out
.
println
(
"Access denied!"
);
System
.
out
.
println
(
"Access denied!"
);
}
}
rs
.
close
();
prep
.
close
();
}
}
/**
/**
...
@@ -250,6 +252,8 @@ public class SQLInjection {
...
@@ -250,6 +252,8 @@ public class SQLInjection {
}
else
{
}
else
{
System
.
out
.
println
(
"Access denied!"
);
System
.
out
.
println
(
"Access denied!"
);
}
}
rs
.
close
();
prep
.
close
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
System
.
out
.
println
(
e
);
System
.
out
.
println
(
e
);
}
}
...
@@ -274,6 +278,8 @@ public class SQLInjection {
...
@@ -274,6 +278,8 @@ public class SQLInjection {
}
else
{
}
else
{
System
.
out
.
println
(
"Access denied!"
);
System
.
out
.
println
(
"Access denied!"
);
}
}
rs
.
close
();
prep
.
close
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
);
System
.
out
.
println
(
e
);
}
}
...
@@ -364,9 +370,11 @@ public class SQLInjection {
...
@@ -364,9 +370,11 @@ public class SQLInjection {
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
System
.
out
.
println
(
rs
.
getString
(
1
)
+
": "
+
rs
.
getString
(
2
));
System
.
out
.
println
(
rs
.
getString
(
1
)
+
": "
+
rs
.
getString
(
2
));
}
}
rs
.
close
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
);
System
.
out
.
println
(
e
);
}
}
prep
.
close
();
}
}
/**
/**
...
@@ -402,7 +410,10 @@ public class SQLInjection {
...
@@ -402,7 +410,10 @@ public class SQLInjection {
System
.
out
.
println
(
"salt: "
+
rs
.
getString
(
"SALT"
));
System
.
out
.
println
(
"salt: "
+
rs
.
getString
(
"SALT"
));
System
.
out
.
println
(
"hash: "
+
rs
.
getString
(
"HASH"
));
System
.
out
.
println
(
"hash: "
+
rs
.
getString
(
"HASH"
));
}
}
rs
.
close
();
prep
.
close
();
stat
.
execute
(
"SET ALLOW_LITERALS ALL"
);
stat
.
execute
(
"SET ALLOW_LITERALS ALL"
);
stat
.
close
();
}
}
/**
/**
...
...
h2/src/test/org/h2/samples/SecurePassword.java
浏览文件 @
2585b4ea
...
@@ -56,11 +56,15 @@ public class SecurePassword {
...
@@ -56,11 +56,15 @@ public class SecurePassword {
prep
=
conn
.
prepareStatement
(
"insert into account(name) values(?)"
);
prep
=
conn
.
prepareStatement
(
"insert into account(name) values(?)"
);
prep
.
setString
(
1
,
"Joe"
);
prep
.
setString
(
1
,
"Joe"
);
prep
.
execute
();
prep
.
execute
();
prep
.
close
();
prep
=
conn
.
prepareStatement
(
prep
=
conn
.
prepareStatement
(
"update account set hash=hash('SHA256', stringtoutf8(salt||?), 10) where name=?"
);
"update account set hash=hash('SHA256', stringtoutf8(salt||?), 10) where name=?"
);
prep
.
setString
(
1
,
"secret"
);
prep
.
setString
(
1
,
"secret"
);
prep
.
setString
(
2
,
"Joe"
);
prep
.
setString
(
2
,
"Joe"
);
prep
.
execute
();
prep
.
execute
();
prep
.
close
();
prep
=
conn
.
prepareStatement
(
prep
=
conn
.
prepareStatement
(
"select * from account where name=? and hash=hash('SHA256', stringtoutf8(salt||?), 10)"
);
"select * from account where name=? and hash=hash('SHA256', stringtoutf8(salt||?), 10)"
);
prep
.
setString
(
1
,
"Joe"
);
prep
.
setString
(
1
,
"Joe"
);
...
@@ -69,6 +73,9 @@ public class SecurePassword {
...
@@ -69,6 +73,9 @@ public class SecurePassword {
while
(
rs
.
next
())
{
while
(
rs
.
next
())
{
System
.
out
.
println
(
rs
.
getString
(
"name"
));
System
.
out
.
println
(
rs
.
getString
(
"name"
));
}
}
rs
.
close
();
prep
.
close
();
stat
.
close
();
conn
.
close
();
conn
.
close
();
}
}
...
...
h2/src/test/org/h2/samples/ShowProgress.java
浏览文件 @
2585b4ea
...
@@ -80,6 +80,8 @@ public class ShowProgress implements DatabaseEventListener {
...
@@ -80,6 +80,8 @@ public class ShowProgress implements DatabaseEventListener {
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:test;DATABASE_EVENT_LISTENER='"
+
getClass
().
getName
()
+
"'"
,
"sa"
,
""
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:test;DATABASE_EVENT_LISTENER='"
+
getClass
().
getName
()
+
"'"
,
"sa"
,
""
);
time
=
System
.
currentTimeMillis
()
-
time
;
time
=
System
.
currentTimeMillis
()
-
time
;
System
.
out
.
println
(
"Done after "
+
time
+
" ms"
);
System
.
out
.
println
(
"Done after "
+
time
+
" ms"
);
prep
.
close
();
stat
.
close
();
conn
.
close
();
conn
.
close
();
}
}
...
...
h2/src/test/org/h2/samples/TriggerPassData.java
浏览文件 @
2585b4ea
...
@@ -49,6 +49,7 @@ public class TriggerPassData implements Trigger {
...
@@ -49,6 +49,7 @@ public class TriggerPassData implements Trigger {
stat
.
execute
(
"INSERT INTO TEST VALUES(1)"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(1)"
);
stat
.
execute
(
"CALL TRIGGER_SET('T1', 'World')"
);
stat
.
execute
(
"CALL TRIGGER_SET('T1', 'World')"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(2)"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(2)"
);
stat
.
close
();
conn
.
close
();
conn
.
close
();
}
}
...
...
h2/src/test/org/h2/samples/TriggerSample.java
浏览文件 @
2585b4ea
...
@@ -47,6 +47,8 @@ public class TriggerSample {
...
@@ -47,6 +47,8 @@ public class TriggerSample {
rs
=
stat
.
executeQuery
(
"SELECT AMOUNT FROM INVOICE_SUM"
);
rs
=
stat
.
executeQuery
(
"SELECT AMOUNT FROM INVOICE_SUM"
);
rs
.
next
();
rs
.
next
();
System
.
out
.
println
(
"The sum is "
+
rs
.
getBigDecimal
(
1
));
System
.
out
.
println
(
"The sum is "
+
rs
.
getBigDecimal
(
1
));
rs
.
close
();
stat
.
close
();
conn
.
close
();
conn
.
close
();
}
}
...
...
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
2585b4ea
...
@@ -1150,7 +1150,7 @@ public abstract class TestBase {
...
@@ -1150,7 +1150,7 @@ public abstract class TestBase {
*/
*/
protected
void
assertEquals
(
Integer
expected
,
Integer
actual
)
{
protected
void
assertEquals
(
Integer
expected
,
Integer
actual
)
{
if
(
expected
==
null
||
actual
==
null
)
{
if
(
expected
==
null
||
actual
==
null
)
{
assertTrue
(
expected
==
actua
l
);
assertTrue
(
expected
==
null
&&
actual
==
nul
l
);
}
else
{
}
else
{
assertEquals
(
expected
.
intValue
(),
actual
.
intValue
());
assertEquals
(
expected
.
intValue
(),
actual
.
intValue
());
}
}
...
@@ -1247,8 +1247,6 @@ public abstract class TestBase {
...
@@ -1247,8 +1247,6 @@ public abstract class TestBase {
}
}
// silly code - makes sure there are no warnings
// silly code - makes sure there are no warnings
reserve
[
0
]
=
reserve
[
1
];
reserve
[
0
]
=
reserve
[
1
];
// actually it is anyway garbage collected
reserve
=
null
;
}
}
/**
/**
...
...
h2/src/test/org/h2/test/bench/Database.java
浏览文件 @
2585b4ea
...
@@ -404,7 +404,7 @@ class Database {
...
@@ -404,7 +404,7 @@ class Database {
*/
*/
void
log
(
String
action
,
String
scale
,
int
value
)
{
void
log
(
String
action
,
String
scale
,
int
value
)
{
if
(
test
.
collect
)
{
if
(
test
.
collect
)
{
results
.
add
(
new
Object
[]
{
action
,
scale
,
new
Integer
(
value
)
});
results
.
add
(
new
Object
[]
{
action
,
scale
,
Integer
.
valueOf
(
value
)
});
}
}
}
}
...
...
h2/src/test/org/h2/test/db/TestCluster.java
浏览文件 @
2585b4ea
...
@@ -216,7 +216,7 @@ public class TestCluster extends TestBase {
...
@@ -216,7 +216,7 @@ public class TestCluster extends TestBase {
// try to connect in standalone mode - should fail
// try to connect in standalone mode - should fail
try
{
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:"
+
port1
+
"/test"
,
user
,
password
);
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:"
+
port1
+
"/test"
,
user
,
password
);
fail
(
"should not be able to connect in standalone mode"
);
fail
(
"should not be able to connect in standalone mode"
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
assertKnownException
(
e
);
...
...
h2/src/test/org/h2/test/db/TestFullText.java
浏览文件 @
2585b4ea
...
@@ -389,7 +389,7 @@ public class TestFullText extends TestBase {
...
@@ -389,7 +389,7 @@ public class TestFullText extends TestBase {
conn
=
getConnection
(
"fullText"
);
conn
=
getConnection
(
"fullText"
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('World', 0, 0)"
);
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('World', 0, 0)"
);
stat
.
execute
(
"CALL "
+
prefix
+
"DROP_ALL()"
);
stat
.
execute
(
"CALL "
+
prefix
+
"DROP_ALL()"
);
...
...
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
2585b4ea
...
@@ -380,7 +380,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -380,7 +380,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertEquals
(
"Hello"
,
rs
.
getString
(
2
));
assertEquals
(
"Hello"
,
rs
.
getString
(
2
));
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"CALL ADD_ROW(2, 'World')"
);
stat
.
executeQuery
(
"CALL ADD_ROW(2, 'World')"
);
stat
.
execute
(
"CREATE ALIAS SELECT_F FOR \""
+
getClass
().
getName
()
+
".select\""
);
stat
.
execute
(
"CREATE ALIAS SELECT_F FOR \""
+
getClass
().
getName
()
+
".select\""
);
rs
=
stat
.
executeQuery
(
"CALL SELECT_F('SELECT * FROM TEST ORDER BY ID')"
);
rs
=
stat
.
executeQuery
(
"CALL SELECT_F('SELECT * FROM TEST ORDER BY ID')"
);
...
@@ -631,7 +631,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
...
@@ -631,7 +631,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
* @return the test array
* @return the test array
*/
*/
public
static
Object
[]
getArray
()
{
public
static
Object
[]
getArray
()
{
return
new
Object
[]
{
new
Integer
(
0
)
,
"Hello"
};
return
new
Object
[]
{
0
,
"Hello"
};
}
}
/**
/**
...
...
h2/src/test/org/h2/test/db/TestOptimizations.java
浏览文件 @
2585b4ea
...
@@ -496,8 +496,8 @@ public class TestOptimizations extends TestBase {
...
@@ -496,8 +496,8 @@ public class TestOptimizations extends TestBase {
}
else
{
}
else
{
int
value
=
random
.
nextInt
();
int
value
=
random
.
nextInt
();
stat
.
execute
(
"insert into test values("
+
i
+
", "
+
value
+
")"
);
stat
.
execute
(
"insert into test values("
+
i
+
", "
+
value
+
")"
);
map
.
put
(
new
Integer
(
i
),
new
Integer
(
value
)
);
map
.
put
(
i
,
value
);
set
.
add
(
new
Integer
(
value
)
);
set
.
add
(
value
);
}
}
break
;
break
;
case
6
:
case
6
:
...
...
h2/src/test/org/h2/test/db/TestQueryCache.java
浏览文件 @
2585b4ea
...
@@ -31,7 +31,8 @@ public class TestQueryCache extends TestBase {
...
@@ -31,7 +31,8 @@ public class TestQueryCache extends TestBase {
Connection
conn
=
getConnection
(
"queryCache;QUERY_CACHE_SIZE=10"
);
Connection
conn
=
getConnection
(
"queryCache;QUERY_CACHE_SIZE=10"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int, name varchar) as select x, space(100) from system_range(1, 1000)"
);
stat
.
execute
(
"create table test(id int, name varchar) as select x, space(100) from system_range(1, 1000)"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"select count(*) from test t1, test t2"
);
PreparedStatement
prep
;
conn
.
prepareStatement
(
"select count(*) from test t1, test t2"
);
long
time
;
long
time
;
ResultSet
rs
;
ResultSet
rs
;
long
first
=
0
;
long
first
=
0
;
...
@@ -42,7 +43,7 @@ public class TestQueryCache extends TestBase {
...
@@ -42,7 +43,7 @@ public class TestQueryCache extends TestBase {
// stat.execute("drop table x");
// stat.execute("drop table x");
time
=
System
.
currentTimeMillis
();
time
=
System
.
currentTimeMillis
();
prep
=
conn
.
prepareStatement
(
"select count(*) from test t1, test t2"
);
prep
=
conn
.
prepareStatement
(
"select count(*) from test t1, test t2"
);
rs
=
prep
.
executeQuery
();
prep
.
executeQuery
();
rs
=
stat
.
executeQuery
(
"select count(*) from test t1, test t2"
);
rs
=
stat
.
executeQuery
(
"select count(*) from test t1, test t2"
);
rs
.
next
();
rs
.
next
();
int
c
=
rs
.
getInt
(
1
);
int
c
=
rs
.
getInt
(
1
);
...
...
h2/src/test/org/h2/test/db/TestRecursiveQueries.java
浏览文件 @
2585b4ea
...
@@ -29,7 +29,7 @@ public class TestRecursiveQueries extends TestBase {
...
@@ -29,7 +29,7 @@ public class TestRecursiveQueries extends TestBase {
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
deleteDb
(
"recursiveQueries"
);
deleteDb
(
"recursiveQueries"
);
Connection
conn
=
getConnection
(
"recursiveQueries"
);
Connection
conn
=
getConnection
(
"recursiveQueries"
);
Statement
stat
=
conn
.
createStatement
()
;
Statement
stat
;
PreparedStatement
prep
,
prep2
;
PreparedStatement
prep
,
prep2
;
ResultSet
rs
;
ResultSet
rs
;
...
...
h2/src/test/org/h2/test/db/TestRights.java
浏览文件 @
2585b4ea
...
@@ -224,13 +224,13 @@ public class TestRights extends TestBase {
...
@@ -224,13 +224,13 @@ public class TestRights extends TestBase {
conn
.
close
();
conn
.
close
();
try
{
try
{
conn
=
getConnection
(
"rights"
,
"Test"
,
getPassword
(
"abc"
));
getConnection
(
"rights"
,
"Test"
,
getPassword
(
"abc"
));
fail
(
"mixed case user name"
);
fail
(
"mixed case user name"
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
assertKnownException
(
e
);
}
}
try
{
try
{
conn
=
getConnection
(
"rights"
,
"TEST"
,
getPassword
(
"abc"
));
getConnection
(
"rights"
,
"TEST"
,
getPassword
(
"abc"
));
fail
(
"wrong password"
);
fail
(
"wrong password"
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
assertKnownException
(
e
);
...
...
h2/src/test/org/h2/test/db/TestTransaction.java
浏览文件 @
2585b4ea
...
@@ -146,7 +146,6 @@ public class TestTransaction extends TestBase {
...
@@ -146,7 +146,6 @@ public class TestTransaction extends TestBase {
if
(!
config
.
memory
)
{
if
(!
config
.
memory
)
{
conn
.
close
();
conn
.
close
();
conn
=
getConnection
(
"transaction"
);
conn
=
getConnection
(
"transaction"
);
stat
=
conn
.
createStatement
();
}
}
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
try
{
try
{
...
@@ -194,7 +193,6 @@ public class TestTransaction extends TestBase {
...
@@ -194,7 +193,6 @@ public class TestTransaction extends TestBase {
if
(!
config
.
memory
)
{
if
(!
config
.
memory
)
{
conn
.
close
();
conn
.
close
();
conn
=
getConnection
(
"transaction"
);
conn
=
getConnection
(
"transaction"
);
stat
=
conn
.
createStatement
();
}
}
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
try
{
try
{
...
...
h2/src/test/org/h2/test/jaqu/UpdateTest.java
浏览文件 @
2585b4ea
...
@@ -56,7 +56,7 @@ public class UpdateTest extends TestBase {
...
@@ -56,7 +56,7 @@ public class UpdateTest extends TestBase {
Product
p2
=
new
Product
();
Product
p2
=
new
Product
();
Product
pChang2
=
db
.
from
(
p2
).
where
(
p2
.
productName
).
is
(
"Chang"
).
selectFirst
();
Product
pChang2
=
db
.
from
(
p2
).
where
(
p2
.
productName
).
is
(
"Chang"
).
selectFirst
();
assertEquals
(
19.5
,
pChang2
.
unitPrice
);
assertEquals
(
19.5
,
pChang2
.
unitPrice
);
assertEquals
(
new
Integer
(
16
),
pChang2
.
unitsInStock
);
assertEquals
(
16
,
pChang2
.
unitsInStock
.
intValue
()
);
// undo update
// undo update
pChang
.
unitPrice
=
19.0
;
pChang
.
unitPrice
=
19.0
;
...
@@ -90,7 +90,7 @@ public class UpdateTest extends TestBase {
...
@@ -90,7 +90,7 @@ public class UpdateTest extends TestBase {
Product
p2
=
new
Product
();
Product
p2
=
new
Product
();
Product
pChang2
=
db
.
from
(
p2
).
where
(
p2
.
productName
).
is
(
"Chang"
).
selectFirst
();
Product
pChang2
=
db
.
from
(
p2
).
where
(
p2
.
productName
).
is
(
"Chang"
).
selectFirst
();
assertEquals
(
19.5
,
pChang2
.
unitPrice
);
assertEquals
(
19.5
,
pChang2
.
unitPrice
);
assertEquals
(
new
Integer
(
16
),
pChang2
.
unitsInStock
);
assertEquals
(
16
,
pChang2
.
unitsInStock
.
intValue
()
);
// undo update
// undo update
pChang
.
unitPrice
=
19.0
;
pChang
.
unitPrice
=
19.0
;
...
...
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
2585b4ea
...
@@ -400,12 +400,12 @@ public class TestPreparedStatement extends TestBase {
...
@@ -400,12 +400,12 @@ public class TestPreparedStatement extends TestBase {
stat
.
execute
(
"CREATE TABLE TEST(ID INT, DATA BINARY, JAVA OTHER)"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT, DATA BINARY, JAVA OTHER)"
);
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST VALUES(?, ?, ?)"
);
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST VALUES(?, ?, ?)"
);
prep
.
setInt
(
1
,
1
);
prep
.
setInt
(
1
,
1
);
prep
.
setObject
(
2
,
new
Integer
(
11
)
);
prep
.
setObject
(
2
,
11
);
prep
.
setObject
(
3
,
null
);
prep
.
setObject
(
3
,
null
);
prep
.
execute
();
prep
.
execute
();
prep
.
setInt
(
1
,
2
);
prep
.
setInt
(
1
,
2
);
prep
.
setObject
(
2
,
new
Integer
(
101
)
,
Types
.
OTHER
);
prep
.
setObject
(
2
,
101
,
Types
.
OTHER
);
prep
.
setObject
(
3
,
new
Integer
(
103
)
,
Types
.
OTHER
);
prep
.
setObject
(
3
,
103
,
Types
.
OTHER
);
prep
.
execute
();
prep
.
execute
();
PreparedStatement
p2
=
conn
.
prepareStatement
(
"SELECT * FROM TEST ORDER BY ID"
);
PreparedStatement
p2
=
conn
.
prepareStatement
(
"SELECT * FROM TEST ORDER BY ID"
);
ResultSet
rs
=
p2
.
executeQuery
();
ResultSet
rs
=
p2
.
executeQuery
();
...
@@ -678,7 +678,7 @@ public class TestPreparedStatement extends TestBase {
...
@@ -678,7 +678,7 @@ public class TestPreparedStatement extends TestBase {
// some databases don't allow calling setObject with null (no data type)
// some databases don't allow calling setObject with null (no data type)
prep
.
executeUpdate
();
prep
.
executeUpdate
();
prep
.
setInt
(
1
,
9
);
prep
.
setInt
(
1
,
9
);
prep
.
setObject
(
2
,
new
Integer
(-
4
)
,
Types
.
VARCHAR
);
prep
.
setObject
(
2
,
-
4
,
Types
.
VARCHAR
);
prep
.
executeUpdate
();
prep
.
executeUpdate
();
prep
.
setInt
(
1
,
10
);
prep
.
setInt
(
1
,
10
);
prep
.
setObject
(
2
,
"5"
,
Types
.
INTEGER
);
prep
.
setObject
(
2
,
"5"
,
Types
.
INTEGER
);
...
@@ -797,7 +797,7 @@ public class TestPreparedStatement extends TestBase {
...
@@ -797,7 +797,7 @@ public class TestPreparedStatement extends TestBase {
assertTrue
(
rs
.
getObject
(
1
).
equals
(
new
Boolean
(
true
)));
assertTrue
(
rs
.
getObject
(
1
).
equals
(
new
Boolean
(
true
)));
assertTrue
(
rs
.
getObject
(
2
).
equals
(
"Abc"
));
assertTrue
(
rs
.
getObject
(
2
).
equals
(
"Abc"
));
assertTrue
(
rs
.
getObject
(
3
).
equals
(
new
BigDecimal
(
"10.2"
)));
assertTrue
(
rs
.
getObject
(
3
).
equals
(
new
BigDecimal
(
"10.2"
)));
assertTrue
(
rs
.
getObject
(
4
).
equals
(
new
Byte
((
byte
)
0xff
)
));
assertTrue
(
rs
.
getObject
(
4
).
equals
(
(
byte
)
0xff
));
assertTrue
(
rs
.
getObject
(
5
).
equals
(
new
Short
(
Short
.
MAX_VALUE
)));
assertTrue
(
rs
.
getObject
(
5
).
equals
(
new
Short
(
Short
.
MAX_VALUE
)));
assertTrue
(
rs
.
getObject
(
6
).
equals
(
new
Integer
(
Integer
.
MIN_VALUE
)));
assertTrue
(
rs
.
getObject
(
6
).
equals
(
new
Integer
(
Integer
.
MIN_VALUE
)));
assertTrue
(
rs
.
getObject
(
7
).
equals
(
new
Long
(
Long
.
MAX_VALUE
)));
assertTrue
(
rs
.
getObject
(
7
).
equals
(
new
Long
(
Long
.
MAX_VALUE
)));
...
@@ -809,7 +809,7 @@ public class TestPreparedStatement extends TestBase {
...
@@ -809,7 +809,7 @@ public class TestPreparedStatement extends TestBase {
assertTrue
(
rs
.
getObject
(
12
).
equals
(
java
.
sql
.
Timestamp
.
valueOf
(
"2001-02-03 04:05:06.123456789"
)));
assertTrue
(
rs
.
getObject
(
12
).
equals
(
java
.
sql
.
Timestamp
.
valueOf
(
"2001-02-03 04:05:06.123456789"
)));
assertTrue
(
rs
.
getObject
(
13
).
equals
(
java
.
sql
.
Timestamp
.
valueOf
(
"2001-02-03 00:00:00"
)));
assertTrue
(
rs
.
getObject
(
13
).
equals
(
java
.
sql
.
Timestamp
.
valueOf
(
"2001-02-03 00:00:00"
)));
assertEquals
(
new
byte
[]
{
10
,
20
,
30
},
(
byte
[])
rs
.
getObject
(
14
));
assertEquals
(
new
byte
[]
{
10
,
20
,
30
},
(
byte
[])
rs
.
getObject
(
14
));
assertTrue
(
rs
.
getObject
(
15
).
equals
(
new
Character
(
'a'
)
));
assertTrue
(
rs
.
getObject
(
15
).
equals
(
'a'
));
assertTrue
(
rs
.
getObject
(
16
).
equals
(
java
.
sql
.
Date
.
valueOf
(
"2001-01-02"
)));
assertTrue
(
rs
.
getObject
(
16
).
equals
(
java
.
sql
.
Date
.
valueOf
(
"2001-01-02"
)));
assertTrue
(
rs
.
getObject
(
17
)
==
null
&&
rs
.
wasNull
());
assertTrue
(
rs
.
getObject
(
17
)
==
null
&&
rs
.
wasNull
());
assertTrue
(
rs
.
getObject
(
18
).
equals
(
new
Double
(
3.725
)));
assertTrue
(
rs
.
getObject
(
18
).
equals
(
new
Double
(
3.725
)));
...
...
h2/src/test/org/h2/test/jdbc/TestResultSet.java
浏览文件 @
2585b4ea
...
@@ -1066,8 +1066,9 @@ public class TestResultSet extends TestBase {
...
@@ -1066,8 +1066,9 @@ public class TestResultSet extends TestBase {
prep
.
setObject
(
2
,
new
Object
[]
{
new
Integer
(
1
),
new
Integer
(
2
)
});
prep
.
setObject
(
2
,
new
Object
[]
{
new
Integer
(
1
),
new
Integer
(
2
)
});
prep
.
execute
();
prep
.
execute
();
prep
.
setInt
(
1
,
2
);
prep
.
setInt
(
1
,
2
);
prep
.
setObject
(
2
,
new
Object
[]
{
new
Integer
(
11
),
new
Integer
(
12
)
});
prep
.
setObject
(
2
,
new
Object
[]
{
11
,
12
});
prep
.
execute
();
prep
.
execute
();
prep
.
close
();
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM TEST ORDER BY ID"
);
rs
.
next
();
rs
.
next
();
assertEquals
(
1
,
rs
.
getInt
(
1
));
assertEquals
(
1
,
rs
.
getInt
(
1
));
...
...
h2/src/test/org/h2/test/jdbc/TestUpdatableResultSet.java
浏览文件 @
2585b4ea
...
@@ -275,7 +275,7 @@ public class TestUpdatableResultSet extends TestBase {
...
@@ -275,7 +275,7 @@ public class TestUpdatableResultSet extends TestBase {
rs
.
updateDouble
(
"DB"
,
1.725
);
rs
.
updateDouble
(
"DB"
,
1.725
);
rs
.
updateFloat
(
"R"
,
(
float
)
2.5
);
rs
.
updateFloat
(
"R"
,
(
float
)
2.5
);
rs
.
updateLong
(
"L"
,
Long
.
MAX_VALUE
);
rs
.
updateLong
(
"L"
,
Long
.
MAX_VALUE
);
rs
.
updateObject
(
"O_I"
,
new
Integer
(
10
)
);
rs
.
updateObject
(
"O_I"
,
10
);
rs
.
updateShort
(
"SH"
,
Short
.
MIN_VALUE
);
rs
.
updateShort
(
"SH"
,
Short
.
MIN_VALUE
);
// auml, ouml, uuml
// auml, ouml, uuml
rs
.
updateCharacterStream
(
"CL"
,
new
StringReader
(
"\u00ef\u00f6\u00fc"
),
0
);
rs
.
updateCharacterStream
(
"CL"
,
new
StringReader
(
"\u00ef\u00f6\u00fc"
),
0
);
...
...
h2/src/test/org/h2/test/synth/TestCrashAPI.java
浏览文件 @
2585b4ea
...
@@ -85,6 +85,7 @@ public class TestCrashAPI extends TestBase implements Runnable {
...
@@ -85,6 +85,7 @@ public class TestCrashAPI extends TestBase implements Runnable {
try
{
try
{
Thread
.
sleep
(
1000
);
Thread
.
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
}
catch
(
InterruptedException
e
)
{
maxWait
++;
// ignore
// ignore
}
}
}
}
...
@@ -409,17 +410,17 @@ public class TestCrashAPI extends TestBase implements Runnable {
...
@@ -409,17 +410,17 @@ public class TestCrashAPI extends TestBase implements Runnable {
private
Object
getRandomParam
(
Class
<?>
type
)
{
private
Object
getRandomParam
(
Class
<?>
type
)
{
if
(
type
==
int
.
class
)
{
if
(
type
==
int
.
class
)
{
return
new
Integer
(
random
.
getRandomInt
()
);
return
random
.
getRandomInt
(
);
}
else
if
(
type
==
byte
.
class
)
{
}
else
if
(
type
==
byte
.
class
)
{
return
new
Byte
((
byte
)
random
.
getRandomInt
()
);
return
(
byte
)
random
.
getRandomInt
(
);
}
else
if
(
type
==
short
.
class
)
{
}
else
if
(
type
==
short
.
class
)
{
return
new
Short
((
short
)
random
.
getRandomInt
()
);
return
(
short
)
random
.
getRandomInt
(
);
}
else
if
(
type
==
long
.
class
)
{
}
else
if
(
type
==
long
.
class
)
{
return
new
Long
(
random
.
getRandomLong
()
);
return
random
.
getRandomLong
(
);
}
else
if
(
type
==
float
.
class
)
{
}
else
if
(
type
==
float
.
class
)
{
return
new
Float
(
random
.
getRandomDouble
()
);
return
(
float
)
random
.
getRandomDouble
(
);
}
else
if
(
type
==
boolean
.
class
)
{
}
else
if
(
type
==
boolean
.
class
)
{
return
new
Boolean
(
random
.
nextBoolean
()
);
return
random
.
nextBoolean
(
);
}
else
if
(
type
==
double
.
class
)
{
}
else
if
(
type
==
double
.
class
)
{
return
new
Double
(
random
.
getRandomDouble
());
return
new
Double
(
random
.
getRandomDouble
());
}
else
if
(
type
==
String
.
class
)
{
}
else
if
(
type
==
String
.
class
)
{
...
...
h2/src/test/org/h2/test/synth/TestJoin.java
浏览文件 @
2585b4ea
...
@@ -141,7 +141,7 @@ public class TestJoin extends TestBase {
...
@@ -141,7 +141,7 @@ public class TestJoin extends TestBase {
String
sql
=
buff
.
toString
();
String
sql
=
buff
.
toString
();
Object
[]
params
=
new
Object
[
paramCount
];
Object
[]
params
=
new
Object
[
paramCount
];
for
(
int
j
=
0
;
j
<
paramCount
;
j
++)
{
for
(
int
j
=
0
;
j
<
paramCount
;
j
++)
{
params
[
j
]
=
random
.
nextInt
(
4
)
==
1
?
null
:
new
Integer
(
random
.
nextInt
(
10
)
-
3
)
;
params
[
j
]
=
random
.
nextInt
(
4
)
==
1
?
null
:
random
.
nextInt
(
10
)
-
3
;
}
}
try
{
try
{
execute
(
sql
,
params
);
execute
(
sql
,
params
);
...
...
h2/src/test/org/h2/test/synth/sql/Value.java
浏览文件 @
2585b4ea
...
@@ -79,11 +79,11 @@ public class Value {
...
@@ -79,11 +79,11 @@ public class Value {
}
}
private
static
Double
randomDouble
(
TestSynth
config
)
{
private
static
Double
randomDouble
(
TestSynth
config
)
{
return
new
Double
(
config
.
random
().
getInt
(
100
)
/
10
.)
;
return
config
.
random
().
getInt
(
100
)
/
10
.
;
}
}
private
static
Long
randomLong
(
TestSynth
config
)
{
private
static
Long
randomLong
(
TestSynth
config
)
{
return
new
Long
(
config
.
random
().
getInt
(
1000
));
return
Long
.
valueOf
(
config
.
random
().
getInt
(
1000
));
}
}
private
static
Time
randomTime
(
TestSynth
config
)
{
private
static
Time
randomTime
(
TestSynth
config
)
{
...
@@ -147,10 +147,10 @@ public class Value {
...
@@ -147,10 +147,10 @@ public class Value {
switch
(
type
)
{
switch
(
type
)
{
case
Types
.
REAL
:
case
Types
.
REAL
:
case
Types
.
DOUBLE
:
case
Types
.
DOUBLE
:
data
=
new
Double
(
rs
.
getDouble
(
index
)
);
data
=
rs
.
getDouble
(
index
);
break
;
break
;
case
Types
.
BIGINT
:
case
Types
.
BIGINT
:
data
=
new
Long
(
rs
.
getLong
(
index
)
);
data
=
rs
.
getLong
(
index
);
break
;
break
;
case
Types
.
DECIMAL
:
case
Types
.
DECIMAL
:
case
Types
.
NUMERIC
:
case
Types
.
NUMERIC
:
...
@@ -179,7 +179,7 @@ public class Value {
...
@@ -179,7 +179,7 @@ public class Value {
data
=
rs
.
getTimestamp
(
index
);
data
=
rs
.
getTimestamp
(
index
);
break
;
break
;
case
Types
.
INTEGER
:
case
Types
.
INTEGER
:
data
=
new
Integer
(
rs
.
getInt
(
index
)
);
data
=
rs
.
getInt
(
index
);
break
;
break
;
case
Types
.
NULL
:
case
Types
.
NULL
:
data
=
null
;
data
=
null
;
...
@@ -260,7 +260,7 @@ public class Value {
...
@@ -260,7 +260,7 @@ public class Value {
}
else
{
}
else
{
value
=
config
.
random
().
getRandomInt
();
value
=
config
.
random
().
getRandomInt
();
}
}
return
new
Integer
(
value
)
;
return
value
;
}
}
private
static
byte
[]
randomBytes
(
TestSynth
config
,
int
max
)
{
private
static
byte
[]
randomBytes
(
TestSynth
config
,
int
max
)
{
...
...
h2/src/test/org/h2/test/test-1.3.txt
浏览文件 @
2585b4ea
--- special grammar and test cases ---------------------------------------------------------------------------------------------
--- special grammar and test cases ---------------------------------------------------------------------------------------------
create table test(d date, t time, ts timestamp);
> ok
insert into test values(date '2001-01-01', time '01:00:00', timestamp '2010-01-01 00:00:00');
> update count: 1
select ts + t x from test;
> X
> ---------------------
> 2010-01-01 01:00:00.0
> rows: 1
select ts + t + t - t x from test;
> X
> ---------------------
> 2010-01-01 01:00:00.0
> rows: 1
select ts + 0.5 * t + t - t x from test;
> X
> ---------------------
> 2010-01-01 00:30:00.0
> rows: 1
select ts + t / 0.5 x from test;
> X
> ---------------------
> 2010-01-01 02:00:00.0
> rows: 1
select d + t, t + d - t x from test;
> T + D X
> --------------------- ---------------------
> 2001-01-01 01:00:00.0 2001-01-01 00:00:00.0
> rows: 1
select 1 + d + 1, d - 1, 2 + ts + 2, ts - 2 from test;
> DATEADD('DAY', 1, DATEADD('DAY', 1, D)) DATEADD('DAY', -1, D) DATEADD('DAY', 2, DATEADD('DAY', 2, TS)) DATEADD('DAY', -2, TS)
> --------------------------------------- --------------------- ---------------------------------------- ----------------------
> 2001-01-03 00:00:00.0 2000-12-31 00:00:00.0 2010-01-05 00:00:00.0 2009-12-30 00:00:00.0
> rows: 1
select 1 + d + t + 1 from test;
> DATEADD('DAY', 1, (T + DATEADD('DAY', 1, D)))
> ---------------------------------------------
> 2001-01-03 01:00:00.0
> rows: 1
select ts - t - 2 from test;
> DATEADD('DAY', -2, (TS - T))
> ----------------------------
> 2009-12-29 23:00:00.0
> rows: 1
drop table test;
> ok
create table test(id int primary key);
create table test(id int primary key);
> ok
> ok
...
...
h2/src/test/org/h2/test/trace/Parser.java
浏览文件 @
2585b4ea
...
@@ -183,16 +183,16 @@ class Parser {
...
@@ -183,16 +183,16 @@ class Parser {
}
else
if
(
tokenType
==
NUMBER
)
{
}
else
if
(
tokenType
==
NUMBER
)
{
String
number
=
readToken
().
toLowerCase
();
String
number
=
readToken
().
toLowerCase
();
if
(
number
.
endsWith
(
"f"
))
{
if
(
number
.
endsWith
(
"f"
))
{
Float
v
=
new
Float
(
Float
.
parseFloat
(
number
)
);
Float
v
=
Float
.
parseFloat
(
number
);
return
new
Arg
(
float
.
class
,
v
);
return
new
Arg
(
float
.
class
,
v
);
}
else
if
(
number
.
endsWith
(
"d"
)
||
number
.
indexOf
(
"e"
)
>=
0
||
number
.
indexOf
(
"."
)
>=
0
)
{
}
else
if
(
number
.
endsWith
(
"d"
)
||
number
.
indexOf
(
"e"
)
>=
0
||
number
.
indexOf
(
"."
)
>=
0
)
{
Double
v
=
new
Double
(
Double
.
parseDouble
(
number
)
);
Double
v
=
Double
.
parseDouble
(
number
);
return
new
Arg
(
double
.
class
,
v
);
return
new
Arg
(
double
.
class
,
v
);
}
else
if
(
number
.
endsWith
(
"L"
)
||
number
.
endsWith
(
"l"
))
{
}
else
if
(
number
.
endsWith
(
"L"
)
||
number
.
endsWith
(
"l"
))
{
Long
v
=
new
Long
(
Long
.
parseLong
(
number
.
substring
(
0
,
number
.
length
()
-
1
)
));
Long
v
=
Long
.
parseLong
(
number
.
substring
(
0
,
number
.
length
()
-
1
));
return
new
Arg
(
long
.
class
,
v
);
return
new
Arg
(
long
.
class
,
v
);
}
else
{
}
else
{
Integer
v
=
new
Integer
(
Integer
.
parseInt
(
number
)
);
Integer
v
=
Integer
.
parseInt
(
number
);
return
new
Arg
(
int
.
class
,
v
);
return
new
Arg
(
int
.
class
,
v
);
}
}
}
else
if
(
tokenType
==
NAME
)
{
}
else
if
(
tokenType
==
NAME
)
{
...
@@ -241,7 +241,7 @@ class Parser {
...
@@ -241,7 +241,7 @@ class Parser {
read
(
"short"
);
read
(
"short"
);
read
(
")"
);
read
(
")"
);
String
number
=
readToken
();
String
number
=
readToken
();
return
new
Arg
(
short
.
class
,
new
Short
(
Short
.
parseShort
(
number
)
));
return
new
Arg
(
short
.
class
,
Short
.
parseShort
(
number
));
}
else
{
}
else
{
throw
new
RuntimeException
(
"Value expected, got: "
+
readToken
()
+
" in "
throw
new
RuntimeException
(
"Value expected, got: "
+
readToken
()
+
" in "
+
line
);
+
line
);
...
...
h2/src/test/org/h2/test/trace/Player.java
浏览文件 @
2585b4ea
...
@@ -110,6 +110,7 @@ public class Player {
...
@@ -110,6 +110,7 @@ public class Player {
}
}
runLine
(
line
.
trim
());
runLine
(
line
.
trim
());
}
}
reader
.
close
();
}
}
/**
/**
...
...
h2/src/test/org/h2/test/unit/TestCache.java
浏览文件 @
2585b4ea
...
@@ -115,7 +115,7 @@ public class TestCache extends TestBase implements CacheWriter {
...
@@ -115,7 +115,7 @@ public class TestCache extends TestBase implements CacheWriter {
/**
/**
* A simple cache object
* A simple cache object
*/
*/
class
Obj
extends
CacheObject
{
static
class
Obj
extends
CacheObject
{
Obj
(
int
pos
)
{
Obj
(
int
pos
)
{
setPos
(
pos
);
setPos
(
pos
);
...
...
h2/src/test/org/h2/test/unit/TestJmx.java
浏览文件 @
2585b4ea
...
@@ -101,7 +101,6 @@ public class TestJmx extends TestBase {
...
@@ -101,7 +101,6 @@ public class TestJmx extends TestBase {
conn
.
close
();
conn
.
close
();
conn
=
getConnection
(
"jmx;jmx=true"
);
conn
=
getConnection
(
"jmx;jmx=true"
);
stat
=
conn
.
createStatement
();
name
=
new
ObjectName
(
"org.h2:name=JMX,*"
);
name
=
new
ObjectName
(
"org.h2:name=JMX,*"
);
Set
<
ObjectName
>
set
=
mbeanServer
.
queryNames
(
name
,
null
);
Set
<
ObjectName
>
set
=
mbeanServer
.
queryNames
(
name
,
null
);
...
...
h2/src/test/org/h2/test/unit/TestNetUtils.java
浏览文件 @
2585b4ea
...
@@ -89,7 +89,7 @@ public class TestNetUtils extends TestBase {
...
@@ -89,7 +89,7 @@ public class TestNetUtils extends TestBase {
/**
/**
* A worker thread to test connecting.
* A worker thread to test connecting.
*/
*/
private
class
ConnectWorker
extends
Thread
{
private
static
class
ConnectWorker
extends
Thread
{
private
final
boolean
ssl
;
private
final
boolean
ssl
;
private
final
AtomicInteger
counter
;
private
final
AtomicInteger
counter
;
...
...
h2/src/test/org/h2/test/unit/TestOldVersion.java
浏览文件 @
2585b4ea
...
@@ -49,7 +49,7 @@ public class TestOldVersion extends TestBase {
...
@@ -49,7 +49,7 @@ public class TestOldVersion extends TestBase {
Server
server
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
"9001"
);
Server
server
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
"-tcpPort"
,
"9001"
);
server
.
start
();
server
.
start
();
try
{
try
{
conn
=
driver
.
connect
(
"jdbc:h2:tcp://localhost:9001/mem:test"
,
null
);
driver
.
connect
(
"jdbc:h2:tcp://localhost:9001/mem:test"
,
null
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
assertEquals
(
ErrorCode
.
DRIVER_VERSION_ERROR_2
,
e
.
getErrorCode
());
assertEquals
(
ErrorCode
.
DRIVER_VERSION_ERROR_2
,
e
.
getErrorCode
());
}
}
...
...
h2/src/test/org/h2/test/unit/TestPageStore.java
浏览文件 @
2585b4ea
...
@@ -715,7 +715,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
...
@@ -715,7 +715,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
Random
random
=
new
Random
(
seed
);
Random
random
=
new
Random
(
seed
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
int
op
=
random
.
nextInt
(
3
);
int
op
=
random
.
nextInt
(
3
);
Integer
x
=
new
Integer
(
random
.
nextInt
(
100
)
);
Integer
x
=
random
.
nextInt
(
100
);
switch
(
op
)
{
switch
(
op
)
{
case
0
:
case
0
:
if
(!
rows
.
contains
(
x
))
{
if
(!
rows
.
contains
(
x
))
{
...
...
h2/src/test/org/h2/test/unit/TestPageStoreCoverage.java
浏览文件 @
2585b4ea
...
@@ -247,6 +247,7 @@ public class TestPageStoreCoverage extends TestBase {
...
@@ -247,6 +247,7 @@ public class TestPageStoreCoverage extends TestBase {
f
.
setFileLength
(
16
);
f
.
setFileLength
(
16
);
// create a new database
// create a new database
conn
=
getConnection
(
"pageStore"
);
conn
=
getConnection
(
"pageStore"
);
conn
.
close
();
deleteDb
(
"pageStore"
);
deleteDb
(
"pageStore"
);
}
}
...
...
h2/src/test/org/h2/test/unit/TestReopen.java
浏览文件 @
2585b4ea
...
@@ -153,7 +153,8 @@ public class TestReopen extends TestBase implements Recorder {
...
@@ -153,7 +153,8 @@ public class TestReopen extends TestBase implements Recorder {
database
.
removeSession
(
null
);
database
.
removeSession
(
null
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
int
errorCode
=
0
;
int
errorCode
=
0
;
if
(
e
instanceof
SQLException
)
{
if
(
e
instanceof
DbException
)
{
e
=
((
DbException
)
e
).
getSQLException
();
errorCode
=
((
SQLException
)
e
).
getErrorCode
();
errorCode
=
((
SQLException
)
e
).
getErrorCode
();
}
}
if
(
errorCode
==
ErrorCode
.
WRONG_USER_OR_PASSWORD
)
{
if
(
errorCode
==
ErrorCode
.
WRONG_USER_OR_PASSWORD
)
{
...
...
h2/src/test/org/h2/test/unit/TestTools.java
浏览文件 @
2585b4ea
...
@@ -668,7 +668,7 @@ public class TestTools extends TestBase {
...
@@ -668,7 +668,7 @@ public class TestTools extends TestBase {
"-baseDir"
,
getBaseDir
(),
"-baseDir"
,
getBaseDir
(),
"-tcpPort"
,
"9192"
).
start
();
"-tcpPort"
,
"9192"
).
start
();
try
{
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9192/test2"
,
"sa"
,
""
);
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9192/test2"
,
"sa"
,
""
);
fail
(
"should not be able to create new db"
);
fail
(
"should not be able to create new db"
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
assertKnownException
(
e
);
...
@@ -707,7 +707,7 @@ public class TestTools extends TestBase {
...
@@ -707,7 +707,7 @@ public class TestTools extends TestBase {
conn
.
close
();
conn
.
close
();
try
{
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9192/../test"
,
"sa"
,
""
);
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9192/../test"
,
"sa"
,
""
);
fail
(
"Should throw an exception!"
);
fail
(
"Should throw an exception!"
);
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
// Expected
// Expected
...
...
h2/src/tools/org/h2/build/BuildBase.java
浏览文件 @
2585b4ea
...
@@ -220,10 +220,10 @@ public class BuildBase {
...
@@ -220,10 +220,10 @@ public class BuildBase {
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
if
(
line
.
length
()
==
0
)
{
if
(
line
==
null
||
line
.
equals
(
"exit"
)
||
line
.
equals
(
"quit"
))
{
line
=
last
;
}
else
if
(
line
.
equals
(
"exit"
)
||
line
.
equals
(
"quit"
))
{
break
;
break
;
}
else
if
(
line
.
length
()
==
0
)
{
line
=
last
;
}
}
long
time
=
System
.
currentTimeMillis
();
long
time
=
System
.
currentTimeMillis
();
try
{
try
{
...
...
h2/src/tools/org/h2/jaqu/Function.java
浏览文件 @
2585b4ea
...
@@ -17,7 +17,7 @@ public class Function implements Token {
...
@@ -17,7 +17,7 @@ public class Function implements Token {
//## Java 1.5 begin ##
//## Java 1.5 begin ##
// must be a new instance
// must be a new instance
private
static
final
Long
COUNT_STAR
=
new
Long
(
0
);
private
static
final
Long
COUNT_STAR
=
Long
.
valueOf
(
0
);
protected
Object
[]
x
;
protected
Object
[]
x
;
private
String
name
;
private
String
name
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论