Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
f5f26b7a
提交
f5f26b7a
authored
2月 14, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
5773980e
隐藏空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
194 行增加
和
93 行删除
+194
-93
ErrorCode.java
h2/src/main/org/h2/constant/ErrorCode.java
+107
-5
SysProperties.java
h2/src/main/org/h2/constant/SysProperties.java
+1
-3
LogSystem.java
h2/src/main/org/h2/log/LogSystem.java
+1
-16
DiskFile.java
h2/src/main/org/h2/store/DiskFile.java
+3
-3
WriterThread.java
h2/src/main/org/h2/store/WriterThread.java
+10
-3
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+5
-13
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+2
-2
TestCluster.java
h2/src/test/org/h2/test/db/TestCluster.java
+16
-16
TestRecover.java
h2/src/test/org/h2/test/poweroff/TestRecover.java
+31
-13
TestPgServer.java
h2/src/test/org/h2/test/server/TestPgServer.java
+3
-3
TestWeb.java
h2/src/test/org/h2/test/server/TestWeb.java
+1
-1
OutputCatcher.java
h2/src/test/org/h2/test/synth/OutputCatcher.java
+1
-1
TestKillRestart.java
h2/src/test/org/h2/test/synth/TestKillRestart.java
+0
-1
TestFtp.java
h2/src/test/org/h2/test/unit/TestFtp.java
+2
-2
TestTools.java
h2/src/test/org/h2/test/unit/TestTools.java
+11
-11
没有找到文件。
h2/src/main/org/h2/constant/ErrorCode.java
浏览文件 @
f5f26b7a
...
...
@@ -4,9 +4,6 @@
*/
package
org
.
h2
.
constant
;
import
java.sql.SQLException
;
import
java.sql.Savepoint
;
/**
* This class defines the error codes used for SQL exceptions.
*/
...
...
@@ -1219,10 +1216,35 @@ public class ErrorCode {
*/
public
static
final
int
INDEX_BELONGS_TO_CONSTRAINT_1
=
90085
;
private
int
todo37
;
/**
* The error with code <code>90086</code> is thrown when
* a class can not be loaded because it is not in the classpath
* or because a related class is not in the classpath.
* Example:
* <pre>
* CREATE ALIAS TEST FOR "java.lang.invalid.Math.sqrt";
* </pre>
*/
public
static
final
int
CLASS_NOT_FOUND_1
=
90086
;
/**
* The error with code <code>90087</code> is thrown when
* the specified method was not found in the class.
* Example:
* <pre>
* CREATE ALIAS TEST FOR "java.lang.Math.test";
* </pre>
*/
public
static
final
int
METHOD_NOT_FOUND_1
=
90087
;
/**
* The error with code <code>90088</code> is thrown when
* trying to switch to an unknown mode.
* Example:
* <pre>
* SET MODE UNKNOWN;
* </pre>
*/
public
static
final
int
UNKNOWN_MODE_1
=
90088
;
/**
...
...
@@ -1230,6 +1252,7 @@ public class ErrorCode {
* trying to change the collation while there was already data in
* the database. The collation of the database must be set when the
* database is empty.
* Example:
* <pre>
* CREATE TABLE TEST(NAME VARCHAR PRIMARY KEY);
* INSERT INTO TEST VALUES('Hello', 'World');
...
...
@@ -1244,7 +1267,26 @@ public class ErrorCode {
* </pre>
*/
public
static
final
int
COLLATION_CHANGE_WITH_DATA_TABLE_1
=
90089
;
/**
* The error with code <code>90090</code> is thrown when
* trying to drop a schema that may not be dropped (the schema PUBLIC
* and the schema INFORMATION_SCHEMA).
* Example:
* <pre>
* DROP SCHEMA PUBLIC;
* </pre>
*/
public
static
final
int
SCHEMA_CAN_NOT_BE_DROPPED_1
=
90090
;
/**
* The error with code <code>90091</code> is thrown when
* trying to drop the role PUBLIC.
* Example:
* <pre>
* DROP ROLE PUBLIC;
* </pre>
*/
public
static
final
int
ROLE_CAN_NOT_BE_DROPPED_1
=
90091
;
/**
...
...
@@ -1255,6 +1297,14 @@ public class ErrorCode {
* source code to JDK 1.3 using ant codeswitchJdk13.
*/
public
static
final
int
UNSUPPORTED_JAVA_VERSION
=
90092
;
/**
* The error with code <code>90093</code> is thrown when
* trying to connect to a clustered database that runs in standalone
* mode. This can happen if clustering is not enabled on the database,
* or if one of the clients disabled clustering because it can not see
* the other cluster node.
*/
public
static
final
int
CLUSTER_ERROR_DATABASE_RUNS_ALONE
=
90093
;
/**
...
...
@@ -1263,8 +1313,35 @@ public class ErrorCode {
* different cluster node setting than what is used when trying to connect.
*/
public
static
final
int
CLUSTER_ERROR_DATABASE_RUNS_CLUSTERED_1
=
90094
;
/**
* The error with code <code>90095</code> is thrown when
* calling the method STRINGDECODE with an invalid escape sequence.
* Only Java style escape sequences and Java properties file escape
* sequences are supported.
* Example:
* <pre>
* CALL STRINGDECODE('\i');
* </pre>
*/
public
static
final
int
STRING_FORMAT_ERROR_1
=
90095
;
/**
* The error with code <code>90096</code> is thrown when
* trying to perform an operation with a non-admin user if the
* user does not have enough rights.
*/
public
static
final
int
NOT_ENOUGH_RIGHTS_FOR_1
=
90096
;
/**
* The error with code <code>90097</code> is thrown when
* trying to delete or update a database if it is open in read-only mode.
* Example:
* <pre>
* jdbc:h2:~/test;ACCESS_MODE_DATA=R
* CREATE TABLE TEST(ID INT);
* </pre>
*/
public
static
final
int
DATABASE_IS_READ_ONLY
=
90097
;
/**
...
...
@@ -1273,9 +1350,34 @@ public class ErrorCode {
* This counter is only used for recovery testing, and not set in normal operation.
*/
public
static
final
int
SIMULATED_POWER_OFF
=
90098
;
/**
* The error with code <code>90099</code> is thrown when
* an error occured trying to initialize the database event listener.
* Example:
* <pre>
* jdbc:h2:~/test;DATABASE_EVENT_LISTENER='java.lang.String'
* </pre>
*/
public
static
final
int
ERROR_SETTING_DATABASE_EVENT_LISTENER_2
=
90099
;
/**
* The error with code <code>90100</code> is thrown when
* there is no more space available on the device where the database
* files are stored.
*/
public
static
final
int
NO_DISK_SPACE_AVAILABLE
=
90100
;
/**
* The error with code <code>90101</code> is thrown when
* the XA API detected unsupported transaction names. This can happen
* when mixing application generated transaction names and transaction names
* generated by this databases XAConnection API.
*/
public
static
final
int
WRONG_XID_FORMAT_1
=
90101
;
private
int
todo25
;
public
static
final
int
UNSUPPORTED_COMPRESSION_OPTIONS_1
=
90102
;
public
static
final
int
UNSUPPORTED_COMPRESSION_ALGORITHM_1
=
90103
;
public
static
final
int
COMPRESSION_ERROR
=
90104
;
...
...
h2/src/main/org/h2/constant/SysProperties.java
浏览文件 @
f5f26b7a
...
...
@@ -289,9 +289,7 @@ public class SysProperties {
* System property <code>h2.redoBufferSize</code> (default: 262144).<br />
* Size of the redo buffer (used at startup when recovering).
*/
private
int
test
;
// public static final int REDO_BUFFER_SIZE = getIntSetting("h2.redoBufferSize", 256 * 1024);
public
static
final
int
REDO_BUFFER_SIZE
=
getIntSetting
(
"h2.redoBufferSize"
,
0
);
public
static
final
int
REDO_BUFFER_SIZE
=
getIntSetting
(
"h2.redoBufferSize"
,
256
*
1024
);
/**
* System property <code>h2.runFinalize</code> (default: true).<br />
...
...
h2/src/main/org/h2/log/LogSystem.java
浏览文件 @
f5f26b7a
...
...
@@ -9,19 +9,17 @@ import java.util.Comparator;
import
java.util.HashMap
;
import
org.h2.api.DatabaseEventListener
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Database
;
import
org.h2.engine.Session
;
import
org.h2.message.Message
;
import
org.h2.message.Trace
;
import
org.h2.store.DataPage
;
import
org.h2.store.DiskFile
;
import
org.h2.store.Record
;
import
org.h2.store.Storage
;
import
org.h2.util.FileUtils
;
import
org.h2.util.ObjectUtils
;
import
org.h2.util.ObjectArray
;
import
org.h2.util.ObjectUtils
;
/**
* The transaction log system is responsible for the write ahead log mechanism used in this database.
...
...
@@ -259,19 +257,6 @@ public class LogSystem {
LogFile
l
=
new
LogFile
(
this
,
0
,
fileNamePrefix
);
activeLogs
.
add
(
l
);
}
int
checkNoMissing
;
if
(
SysProperties
.
getIntSetting
(
SysProperties
.
H2_LOG_DELETE_DELAY
,
0
)
>
0
)
{
LogFile
last
=
null
;
for
(
int
i
=
0
;
i
<
activeLogs
.
size
();
i
++)
{
LogFile
current
=
(
LogFile
)
activeLogs
.
get
(
i
);
if
(
last
!=
null
&&
last
.
getId
()
+
1
!=
current
.
getId
())
{
throw
Message
.
getInternalError
(
"Missing log file: "
+
last
.
getId
()
+
", "
+
current
.
getId
());
}
last
=
current
;
}
}
currentLog
=
(
LogFile
)
activeLogs
.
get
(
activeLogs
.
size
()
-
1
);
}
...
...
h2/src/main/org/h2/store/DiskFile.java
浏览文件 @
f5f26b7a
...
...
@@ -592,10 +592,10 @@ public class DiskFile implements CacheWriter {
used
.
clear
(
i
);
if
((
i
%
BLOCKS_PER_PAGE
==
0
)
&&
(
pos
+
blockCount
>=
i
+
BLOCKS_PER_PAGE
))
{
// if this is the first page of a block and if the whole page is free
int
disabledCurrently
;
// setPageOwner(getPage(i), FREE_PAGE);
if
(!
logChanges
)
{
setPageOwner
(
getPage
(
i
),
FREE_PAGE
);
}
}
}
}
...
...
h2/src/main/org/h2/store/WriterThread.java
浏览文件 @
f5f26b7a
...
...
@@ -39,6 +39,7 @@ public class WriterThread extends Thread {
private
int
writeDelay
;
private
long
lastIndexFlush
;
private
volatile
boolean
stop
;
private
long
oldLogFileDelete
;
private
String
oldLogFile
;
private
WriterThread
(
Database
database
,
int
writeDelay
)
{
...
...
@@ -110,9 +111,12 @@ public class WriterThread extends Thread {
while
(!
stop
)
{
synchronized
(
this
)
{
if
(
oldLogFile
!=
null
)
{
FileUtils
.
tryDelete
(
oldLogFile
);
if
(!
FileUtils
.
exists
(
oldLogFile
))
{
oldLogFile
=
null
;
long
time
=
System
.
currentTimeMillis
();
if
(
time
>
oldLogFileDelete
)
{
FileUtils
.
tryDelete
(
oldLogFile
);
if
(!
FileUtils
.
exists
(
oldLogFile
))
{
oldLogFile
=
null
;
}
}
}
}
...
...
@@ -158,6 +162,9 @@ public class WriterThread extends Thread {
FileUtils
.
delete
(
oldLogFile
);
}
oldLogFile
=
fileName
;
if
(
fileName
!=
null
)
{
oldLogFileDelete
=
System
.
currentTimeMillis
()
+
SysProperties
.
getLogFileDeleteDelay
();
}
}
}
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
f5f26b7a
...
...
@@ -155,15 +155,8 @@ java org.h2.test.TestAll timer
TestAll
test
=
new
TestAll
();
test
.
printSystem
();
int
test2
;
// System.setProperty(SysProperties.H2_LOG_DELETE_DELAY, "2");
// TestRecover.main(new String[0]);
/*
valentine
the user should be allowed to do everything with his own temp tables (and views).
CREATE USER IF NOT EXISTS READER PASSWORD 'READER';
<login as READER>
...
...
@@ -176,9 +169,7 @@ Automate real power off tests
Extend tests that simulate power off
timer test
Can sometimes not delete log file?
Test delayed log files delete
Can sometimes not delete log file? need test case
link to new changelog and roadmap, remove pages from google groups
...
...
@@ -204,8 +195,8 @@ ALTER TABLE ALTER COLUMN RESTART and ALTER SEQUENCE now support an expressions.
When setting the base directory on the command line, the user directory prefix ('~') was ignored.
Roadmap:
BIT VARYING
BIT VARYING
(PostgreSQL)
Bitwise AND operator (1 & 3) (PostgreSQL, MySQL)
*/
if
(
args
.
length
>
0
)
{
...
...
@@ -542,7 +533,8 @@ BIT VARYING
FileSystemDisk
.
getInstance
().
deleteRecursive
(
"trace.db"
);
if
(
networked
)
{
TcpServer
.
logInternalErrors
=
true
;
String
[]
args
=
ssl
?
new
String
[]
{
"-tcpSSL"
,
"true"
}
:
new
String
[
0
];
String
[]
args
=
ssl
?
new
String
[]
{
"-tcpSSL"
,
"true"
,
"-tcpPort"
,
"9192"
}
:
new
String
[]
{
"-tcpPort"
,
"9192"
};
server
=
Server
.
createTcpServer
(
args
);
try
{
server
.
start
();
...
...
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
f5f26b7a
...
...
@@ -99,9 +99,9 @@ public abstract class TestBase {
}
if
(
config
.
networked
)
{
if
(
config
.
ssl
)
{
url
=
"ssl://localhost:9
0
92/"
+
name
;
url
=
"ssl://localhost:9
1
92/"
+
name
;
}
else
{
url
=
"tcp://localhost:9
0
92/"
+
name
;
url
=
"tcp://localhost:9
1
92/"
+
name
;
}
}
else
{
url
=
name
;
...
...
h2/src/test/org/h2/test/db/TestCluster.java
浏览文件 @
f5f26b7a
...
...
@@ -49,40 +49,40 @@ public class TestCluster extends TestBase {
CreateCluster
.
main
(
new
String
[]
{
"-urlSource"
,
"jdbc:h2:file:"
+
baseDir
+
"/node1/test"
,
"-urlTarget"
,
"jdbc:h2:file:"
+
baseDir
+
"/node2/test"
,
"-user"
,
"sa"
,
"-serverlist"
,
"localhost:9
091,localhost:90
92"
});
"localhost:9
191,localhost:91
92"
});
Server
n1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
new
String
[]
{
"-tcpPort"
,
"9
0
91"
,
"-baseDir"
,
baseDir
+
"/node1"
}).
start
();
new
String
[]
{
"-tcpPort"
,
"9
1
91"
,
"-baseDir"
,
baseDir
+
"/node1"
}).
start
();
Server
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
new
String
[]
{
"-tcpPort"
,
"9
0
92"
,
"-baseDir"
,
baseDir
+
"/node2"
}).
start
();
new
String
[]
{
"-tcpPort"
,
"9
1
92"
,
"-baseDir"
,
baseDir
+
"/node2"
}).
start
();
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9
0
91/test"
,
"sa"
,
""
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9
1
91/test"
,
"sa"
,
""
);
error
(
"should not be able to connect in standalone mode"
);
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9
0
92/test"
,
"sa"
,
""
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9
1
92/test"
,
"sa"
,
""
);
error
(
"should not be able to connect in standalone mode"
);
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
// test regular cluster connection
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9
091,localhost:90
92/test"
,
"sa"
,
""
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9
191,localhost:91
92/test"
,
"sa"
,
""
);
check
(
conn
,
len
);
conn
.
close
();
// test if only one server is available at the beginning
n2
.
stop
();
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9
091,localhost:90
92/test"
,
"sa"
,
""
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9
191,localhost:91
92/test"
,
"sa"
,
""
);
stat
=
conn
.
createStatement
();
check
(
conn
,
len
);
conn
.
close
();
// disable the cluster
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9
0
91/test;CLUSTER=''"
,
"sa"
,
""
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9
1
91/test;CLUSTER=''"
,
"sa"
,
""
);
conn
.
close
();
n1
.
stop
();
...
...
@@ -90,13 +90,13 @@ public class TestCluster extends TestBase {
DeleteDbFiles
.
main
(
new
String
[]
{
"-dir"
,
baseDir
+
"/node2"
,
"-quiet"
});
CreateCluster
.
main
(
new
String
[]
{
"-urlSource"
,
"jdbc:h2:file:"
+
baseDir
+
"/node1/test"
,
"-urlTarget"
,
"jdbc:h2:file:"
+
baseDir
+
"/node2/test"
,
"-user"
,
"sa"
,
"-serverlist"
,
"localhost:9
091,localhost:90
92"
});
"localhost:9
191,localhost:91
92"
});
n1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
new
String
[]
{
"-tcpPort"
,
"9
0
91"
,
"-baseDir"
,
baseDir
+
"/node1"
}).
start
();
new
String
[]
{
"-tcpPort"
,
"9
1
91"
,
"-baseDir"
,
baseDir
+
"/node1"
}).
start
();
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
new
String
[]
{
"-tcpPort"
,
"9
0
92"
,
"-baseDir"
,
baseDir
+
"/node2"
}).
start
();
new
String
[]
{
"-tcpPort"
,
"9
1
92"
,
"-baseDir"
,
baseDir
+
"/node2"
}).
start
();
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9
091,localhost:90
92/test"
,
"sa"
,
""
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9
191,localhost:91
92/test"
,
"sa"
,
""
);
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE BOTH(ID INT)"
);
...
...
@@ -106,16 +106,16 @@ public class TestCluster extends TestBase {
conn
.
close
();
n2
.
stop
();
n1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
new
String
[]
{
"-tcpPort"
,
"9
0
91"
,
"-baseDir"
,
baseDir
+
"/node1"
})
n1
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
new
String
[]
{
"-tcpPort"
,
"9
1
91"
,
"-baseDir"
,
baseDir
+
"/node1"
})
.
start
();
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9
0
91/test;CLUSTER=''"
,
"sa"
,
""
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9
1
91/test;CLUSTER=''"
,
"sa"
,
""
);
check
(
conn
,
len
);
conn
.
close
();
n1
.
stop
();
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
new
String
[]
{
"-tcpPort"
,
"9
0
92"
,
"-baseDir"
,
baseDir
+
"/node2"
})
n2
=
org
.
h2
.
tools
.
Server
.
createTcpServer
(
new
String
[]
{
"-tcpPort"
,
"9
1
92"
,
"-baseDir"
,
baseDir
+
"/node2"
})
.
start
();
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9
0
92/test;CLUSTER=''"
,
"sa"
,
""
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost:9
1
92/test;CLUSTER=''"
,
"sa"
,
""
);
check
(
conn
,
len
);
conn
.
createStatement
().
execute
(
"SELECT * FROM A"
);
conn
.
close
();
...
...
h2/src/test/org/h2/test/poweroff/TestRecover.java
浏览文件 @
f5f26b7a
...
...
@@ -44,7 +44,7 @@ public class TestRecover {
private
static
final
String
TEST_DIRECTORY
=
DIR
+
"/data"
+
NODE
;
private
static
final
String
BACKUP_DIRECTORY
=
DIR
+
"/last"
;
private
static
final
String
URL
=
System
.
getProperty
(
"test.url"
,
"jdbc:h2:"
+
TEST_DIRECTORY
+
"/test"
);
private
static
final
String
URL
=
System
.
getProperty
(
"test.url"
,
"jdbc:h2:"
+
TEST_DIRECTORY
+
"/test
;MAX_LOG_SIZE=2
"
);
private
static
final
String
DRIVER
=
System
.
getProperty
(
"test.driver"
,
"org.h2.Driver"
);
public
static
void
main
(
String
[]
args
)
throws
Exception
{
...
...
@@ -205,7 +205,9 @@ public class TestRecover {
private
void
runOneTest
(
int
i
)
throws
Exception
{
Random
random
=
new
Random
(
i
);
Connection
conn
=
openConnection
();
PreparedStatement
prep
=
null
;
PreparedStatement
prepInsert
=
null
;
PreparedStatement
prepDelete
=
null
;
conn
.
setAutoCommit
(
false
);
for
(
int
id
=
0
;;
id
++)
{
boolean
rollback
=
random
.
nextInt
(
10
)
==
1
;
int
len
;
...
...
@@ -218,21 +220,35 @@ public class TestRecover {
// make the length odd
len
++;
}
byte
[]
data
=
new
byte
[
len
];
random
.
nextBytes
(
data
);
//
byte[] data = new byte[len];
//
random.nextBytes(data);
int
op
=
random
.
nextInt
();
if
(
op
%
1000
==
0
)
{
if
(
op
%
1000
000
==
0
)
{
closeConnection
(
conn
);
conn
=
openConnection
();
prep
=
null
;
}
if
(
prep
==
null
)
{
prep
=
conn
.
prepareStatement
(
"INSERT INTO TEST(ID, NAME) VALUES(?, ?)"
);
conn
.
setAutoCommit
(
false
);
prepInsert
=
null
;
prepDelete
=
null
;
}
if
(
random
.
nextBoolean
())
{
if
(
prepInsert
==
null
)
{
prepInsert
=
conn
.
prepareStatement
(
"INSERT INTO TEST(ID, NAME) VALUES(?, ?)"
);
}
prepInsert
.
setInt
(
1
,
id
);
prepInsert
.
setString
(
2
,
""
+
len
);
prepInsert
.
execute
();
}
else
{
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT COUNT(*) FROM TEST"
);
rs
.
next
();
int
count
=
rs
.
getInt
(
1
);
rs
.
close
();
if
(
count
>
1000
)
{
if
(
prepDelete
==
null
)
{
prepDelete
=
conn
.
prepareStatement
(
"DELETE FROM TEST WHERE ROWNUM <= 4"
);
}
prepDelete
.
execute
();
}
}
prep
.
setInt
(
1
,
id
);
prep
.
setString
(
2
,
""
+
len
);
prep
.
execute
();
if
(
rollback
)
{
conn
.
rollback
();
}
else
{
...
...
@@ -258,7 +274,9 @@ public class TestRecover {
conn
=
openConnection
();
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"SELECT * FROM TEST"
);
int
max
=
0
;
int
count
=
0
;
while
(
rs
.
next
())
{
count
++;
int
id
=
rs
.
getInt
(
"ID"
);
String
name
=
rs
.
getString
(
"NAME"
);
int
value
=
Integer
.
parseInt
(
name
);
...
...
@@ -269,7 +287,7 @@ public class TestRecover {
}
rs
.
close
();
closeConnection
(
conn
);
System
.
out
.
println
(
"max row
s: "
+
max
);
System
.
out
.
println
(
"max row
id: "
+
max
+
" rows: "
+
count
);
return
true
;
}
catch
(
Throwable
t
)
{
t
.
printStackTrace
();
...
...
h2/src/test/org/h2/test/server/TestPgServer.java
浏览文件 @
f5f26b7a
...
...
@@ -23,7 +23,7 @@ public class TestPgServer extends TestBase {
public
void
test
()
throws
Exception
{
deleteDb
(
"test"
);
Server
server
=
Server
.
createPgServer
(
new
String
[]{
"-baseDir"
,
baseDir
,
"-ifExists"
,
"false"
,
"-pgAllowOthers"
,
"false"
});
Server
server
=
Server
.
createPgServer
(
new
String
[]{
"-baseDir"
,
baseDir
,
"-ifExists"
,
"false"
,
"-pgAllowOthers"
,
"false"
,
"-pgPort"
,
"5535"
});
server
.
start
();
try
{
Class
.
forName
(
"org.postgresql.Driver"
);
...
...
@@ -36,7 +36,7 @@ public class TestPgServer extends TestBase {
}
private
void
testPgClient
()
throws
Exception
{
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:postgresql://localhost:5
4
35/test"
,
"sa"
,
"sa"
);
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:postgresql://localhost:5
5
35/test"
,
"sa"
,
"sa"
);
Statement
stat
=
conn
.
createStatement
();
try
{
stat
.
execute
(
"select ***"
);
...
...
@@ -45,7 +45,7 @@ public class TestPgServer extends TestBase {
// expected
}
conn
.
close
();
conn
=
DriverManager
.
getConnection
(
"jdbc:postgresql://localhost:5
4
35/test"
,
"sa"
,
"sa"
);
conn
=
DriverManager
.
getConnection
(
"jdbc:postgresql://localhost:5
5
35/test"
,
"sa"
,
"sa"
);
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int primary key, name varchar)"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"insert into test values(?, ?)"
);
...
...
h2/src/test/org/h2/test/server/TestWeb.java
浏览文件 @
f5f26b7a
...
...
@@ -13,7 +13,7 @@ import org.h2.tools.Server;
public
class
TestWeb
extends
TestBase
{
public
void
test
()
throws
Exception
{
Server
server
=
Server
.
createWebServer
(
new
String
[
0
]
);
Server
server
=
Server
.
createWebServer
(
new
String
[
]{
"-webPort"
,
"8182"
}
);
server
.
start
();
String
url
=
server
.
getURL
();
WebClient
client
=
new
WebClient
();
...
...
h2/src/test/org/h2/test/synth/OutputCatcher.java
浏览文件 @
f5f26b7a
...
...
@@ -61,7 +61,7 @@ class OutputCatcher extends Thread {
buff
.
append
((
char
)
x
);
}
}
catch
(
IOException
e
)
{
// ignore
break
;
}
}
IOUtils
.
closeSilently
(
in
);
...
...
h2/src/test/org/h2/test/synth/TestKillRestart.java
浏览文件 @
f5f26b7a
...
...
@@ -9,7 +9,6 @@ import java.sql.Connection;
import
java.sql.DriverManager
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.util.Random
;
...
...
h2/src/test/org/h2/test/unit/TestFtp.java
浏览文件 @
f5f26b7a
...
...
@@ -22,10 +22,10 @@ public class TestFtp extends TestBase implements FtpEventListener {
}
private
void
test
(
String
dir
)
throws
Exception
{
Server
server
=
Server
.
createFtpServer
(
new
String
[]{
"-ftpDir"
,
dir
}).
start
();
Server
server
=
Server
.
createFtpServer
(
new
String
[]{
"-ftpDir"
,
dir
,
"-ftpPort"
,
"8121"
}).
start
();
FtpServer
ftp
=
(
FtpServer
)
server
.
getService
();
ftp
.
setEventListener
(
this
);
FtpClient
client
=
FtpClient
.
open
(
"localhost:8
0
21"
);
FtpClient
client
=
FtpClient
.
open
(
"localhost:8
1
21"
);
client
.
login
(
"sa"
,
"sa"
);
client
.
makeDirectory
(
"test"
);
client
.
changeWorkingDirectory
(
"test"
);
...
...
h2/src/test/org/h2/test/unit/TestTools.java
浏览文件 @
f5f26b7a
...
...
@@ -259,9 +259,9 @@ public class TestTools extends TestBase {
private
void
testManagementDb
()
throws
Exception
{
int
count
=
getSize
(
2
,
10
);
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
Server
server
=
Server
.
createTcpServer
(
new
String
[]
{}).
start
();
Server
server
=
Server
.
createTcpServer
(
new
String
[]
{
"-tcpPort"
,
"9192"
}).
start
();
server
.
stop
();
server
=
Server
.
createTcpServer
(
new
String
[]
{
"-tcpPassword"
,
"abc"
}).
start
();
server
=
Server
.
createTcpServer
(
new
String
[]
{
"-tcpPassword"
,
"abc"
,
"-tcpPort"
,
"9192"
}).
start
();
server
.
stop
();
}
}
...
...
@@ -387,33 +387,33 @@ public class TestTools extends TestBase {
private
void
testServer
()
throws
Exception
{
Connection
conn
;
deleteDb
(
"test"
);
Server
server
=
Server
.
createTcpServer
(
new
String
[]
{
"-ifExists"
,
"false"
,
"-baseDir"
,
baseDir
}).
start
();
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost/test"
,
"sa"
,
""
);
Server
server
=
Server
.
createTcpServer
(
new
String
[]
{
"-ifExists"
,
"false"
,
"-baseDir"
,
baseDir
,
"-tcpPort"
,
"9192"
}).
start
();
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost
:9192
/test"
,
"sa"
,
""
);
conn
.
close
();
server
.
stop
();
server
=
Server
.
createTcpServer
(
new
String
[]
{
"-ifExists"
,
"true"
,
"-tcpPassword"
,
"abc"
,
"-baseDir"
,
baseDir
}).
start
();
new
String
[]
{
"-ifExists"
,
"true"
,
"-tcpPassword"
,
"abc"
,
"-baseDir"
,
baseDir
,
"-tcpPort"
,
"9192"
}).
start
();
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost/test2"
,
"sa"
,
""
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost
:9192
/test2"
,
"sa"
,
""
);
error
(
"should not be able to create new db"
);
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost/test"
,
"sa"
,
""
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost
:9192
/test"
,
"sa"
,
""
);
conn
.
close
();
try
{
Server
.
shutdownTcpServer
(
"tcp://localhost"
,
""
,
true
);
Server
.
shutdownTcpServer
(
"tcp://localhost
:9192
"
,
""
,
true
);
error
(
"shouldn't work and should throw an exception"
);
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
}
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost/test"
,
"sa"
,
""
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost
:9192
/test"
,
"sa"
,
""
);
// conn.close();
Server
.
shutdownTcpServer
(
"tcp://localhost"
,
"abc"
,
true
);
Server
.
shutdownTcpServer
(
"tcp://localhost
:9192
"
,
"abc"
,
true
);
// check that the database is closed
deleteDb
(
"test"
);
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost/test"
,
"sa"
,
""
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:tcp://localhost
:9192
/test"
,
"sa"
,
""
);
error
(
"server must have been closed"
);
}
catch
(
SQLException
e
)
{
checkNotGeneralException
(
e
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论