Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
0a92f254
提交
0a92f254
authored
10月 11, 2016
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use try-with-resources where feasible
上级
6a89e09b
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
36 个修改的文件
包含
108 行增加
和
347 行删除
+108
-347
ScriptCommand.java
h2/src/main/org/h2/command/dml/ScriptCommand.java
+3
-8
ConditionInSelect.java
h2/src/main/org/h2/expression/ConditionInSelect.java
+1
-4
Function.java
h2/src/main/org/h2/expression/Function.java
+2
-5
Subquery.java
h2/src/main/org/h2/expression/Subquery.java
+1
-4
JdbcBlob.java
h2/src/main/org/h2/jdbc/JdbcBlob.java
+2
-6
JdbcClob.java
h2/src/main/org/h2/jdbc/JdbcClob.java
+1
-5
JdbcXAConnection.java
h2/src/main/org/h2/jdbcx/JdbcXAConnection.java
+10
-25
LocalResult.java
h2/src/main/org/h2/result/LocalResult.java
+1
-1
ResultInterface.java
h2/src/main/org/h2/result/ResultInterface.java
+1
-1
TcpServer.java
h2/src/main/org/h2/server/TcpServer.java
+2
-5
PgServerThread.java
h2/src/main/org/h2/server/pg/PgServerThread.java
+2
-8
WebApp.java
h2/src/main/org/h2/server/web/WebApp.java
+4
-12
FileLister.java
h2/src/main/org/h2/store/FileLister.java
+1
-13
FileLock.java
h2/src/main/org/h2/store/FileLock.java
+1
-4
FilePathZip.java
h2/src/main/org/h2/store/fs/FilePathZip.java
+4
-16
TableLink.java
h2/src/main/org/h2/table/TableLink.java
+2
-7
Restore.java
h2/src/main/org/h2/tools/Restore.java
+2
-6
Script.java
h2/src/main/org/h2/tools/Script.java
+2
-6
SortedProperties.java
h2/src/main/org/h2/util/SortedProperties.java
+2
-8
SourceCompiler.java
h2/src/main/org/h2/util/SourceCompiler.java
+1
-1
Utils.java
h2/src/main/org/h2/util/Utils.java
+2
-4
ValueLob.java
h2/src/main/org/h2/value/ValueLob.java
+4
-11
ValueLobDb.java
h2/src/main/org/h2/value/ValueLobDb.java
+2
-5
FileFunctions.java
h2/src/test/org/h2/samples/FileFunctions.java
+1
-4
Database.java
h2/src/test/org/h2/test/bench/Database.java
+2
-11
Profile.java
h2/src/test/org/h2/test/coverage/Profile.java
+3
-10
TestLinkedTable.java
h2/src/test/org/h2/test/db/TestLinkedTable.java
+1
-5
TestListener.java
h2/src/test/org/h2/test/db/TestListener.java
+4
-12
TestMultiThread.java
h2/src/test/org/h2/test/db/TestMultiThread.java
+5
-11
TestSequence.java
h2/src/test/org/h2/test/db/TestSequence.java
+1
-5
TestSpatial.java
h2/src/test/org/h2/test/db/TestSpatial.java
+23
-82
TestLimitUpdates.java
h2/src/test/org/h2/test/jdbc/TestLimitUpdates.java
+2
-8
TestRecover.java
h2/src/test/org/h2/test/poweroff/TestRecover.java
+3
-7
TestHalt.java
h2/src/test/org/h2/test/synth/TestHalt.java
+3
-9
TestBnf.java
h2/src/test/org/h2/test/unit/TestBnf.java
+6
-13
TestFileLockSerialized.java
h2/src/test/org/h2/test/unit/TestFileLockSerialized.java
+1
-5
没有找到文件。
h2/src/main/org/h2/command/dml/ScriptCommand.java
浏览文件 @
0a92f254
...
@@ -466,8 +466,7 @@ public class ScriptCommand extends ScriptBase {
...
@@ -466,8 +466,7 @@ public class ScriptCommand extends ScriptBase {
switch
(
v
.
getType
())
{
switch
(
v
.
getType
())
{
case
Value
.
BLOB
:
{
case
Value
.
BLOB
:
{
byte
[]
bytes
=
new
byte
[
lobBlockSize
];
byte
[]
bytes
=
new
byte
[
lobBlockSize
];
InputStream
input
=
v
.
getInputStream
();
try
(
InputStream
input
=
v
.
getInputStream
())
{
try
{
for
(
int
i
=
0
;;
i
++)
{
for
(
int
i
=
0
;;
i
++)
{
StringBuilder
buff
=
new
StringBuilder
(
lobBlockSize
*
2
);
StringBuilder
buff
=
new
StringBuilder
(
lobBlockSize
*
2
);
buff
.
append
(
"INSERT INTO SYSTEM_LOB_STREAM VALUES("
+
id
+
buff
.
append
(
"INSERT INTO SYSTEM_LOB_STREAM VALUES("
+
id
+
...
@@ -480,15 +479,13 @@ public class ScriptCommand extends ScriptBase {
...
@@ -480,15 +479,13 @@ public class ScriptCommand extends ScriptBase {
String
sql
=
buff
.
toString
();
String
sql
=
buff
.
toString
();
add
(
sql
,
true
);
add
(
sql
,
true
);
}
}
}
finally
{
IOUtils
.
closeSilently
(
input
);
}
}
break
;
break
;
}
}
case
Value
.
CLOB
:
{
case
Value
.
CLOB
:
{
char
[]
chars
=
new
char
[
lobBlockSize
];
char
[]
chars
=
new
char
[
lobBlockSize
];
Reader
reader
=
v
.
getReader
();
try
{
try
(
Reader
reader
=
v
.
getReader
())
{
for
(
int
i
=
0
;;
i
++)
{
for
(
int
i
=
0
;;
i
++)
{
StringBuilder
buff
=
new
StringBuilder
(
lobBlockSize
*
2
);
StringBuilder
buff
=
new
StringBuilder
(
lobBlockSize
*
2
);
buff
.
append
(
"INSERT INTO SYSTEM_LOB_STREAM VALUES("
+
id
+
", "
+
i
+
", "
);
buff
.
append
(
"INSERT INTO SYSTEM_LOB_STREAM VALUES("
+
id
+
", "
+
i
+
", "
);
...
@@ -501,8 +498,6 @@ public class ScriptCommand extends ScriptBase {
...
@@ -501,8 +498,6 @@ public class ScriptCommand extends ScriptBase {
String
sql
=
buff
.
toString
();
String
sql
=
buff
.
toString
();
add
(
sql
,
true
);
add
(
sql
,
true
);
}
}
}
finally
{
IOUtils
.
closeSilently
(
reader
);
}
}
break
;
break
;
}
}
...
...
h2/src/main/org/h2/expression/ConditionInSelect.java
浏览文件 @
0a92f254
...
@@ -46,8 +46,7 @@ public class ConditionInSelect extends Condition {
...
@@ -46,8 +46,7 @@ public class ConditionInSelect extends Condition {
if
(!
query
.
hasOrder
())
{
if
(!
query
.
hasOrder
())
{
query
.
setDistinct
(
true
);
query
.
setDistinct
(
true
);
}
}
LocalResult
rows
=
query
.
query
(
0
);
try
(
LocalResult
rows
=
query
.
query
(
0
))
{
try
{
Value
l
=
left
.
getValue
(
session
);
Value
l
=
left
.
getValue
(
session
);
if
(
rows
.
getRowCount
()
==
0
)
{
if
(
rows
.
getRowCount
()
==
0
)
{
return
ValueBoolean
.
get
(
all
);
return
ValueBoolean
.
get
(
all
);
...
@@ -73,8 +72,6 @@ public class ConditionInSelect extends Condition {
...
@@ -73,8 +72,6 @@ public class ConditionInSelect extends Condition {
return
ValueNull
.
INSTANCE
;
return
ValueNull
.
INSTANCE
;
}
}
return
ValueBoolean
.
get
(
false
);
return
ValueBoolean
.
get
(
false
);
}
finally
{
rows
.
close
();
}
}
}
}
...
...
h2/src/main/org/h2/expression/Function.java
浏览文件 @
0a92f254
...
@@ -122,7 +122,7 @@ public class Function extends Expression implements FunctionCall {
...
@@ -122,7 +122,7 @@ public class Function extends Expression implements FunctionCall {
NVL2
=
228
,
DECODE
=
229
,
ARRAY_CONTAINS
=
230
,
FILE_WRITE
=
232
;
NVL2
=
228
,
DECODE
=
229
,
ARRAY_CONTAINS
=
230
,
FILE_WRITE
=
232
;
public
static
final
int
REGEXP_LIKE
=
240
;
public
static
final
int
REGEXP_LIKE
=
240
;
/**
/**
* Used in MySQL-style INSERT ... ON DUPLICATE KEY UPDATE ... VALUES
* Used in MySQL-style INSERT ... ON DUPLICATE KEY UPDATE ... VALUES
*/
*/
...
@@ -1636,12 +1636,9 @@ public class Function extends Expression implements FunctionCall {
...
@@ -1636,12 +1636,9 @@ public class Function extends Expression implements FunctionCall {
String
fileName
=
v1
.
getString
();
String
fileName
=
v1
.
getString
();
try
{
try
{
FileOutputStream
fileOutputStream
=
new
FileOutputStream
(
fileName
);
FileOutputStream
fileOutputStream
=
new
FileOutputStream
(
fileName
);
InputStream
in
=
v0
.
getInputStream
();
try
(
InputStream
in
=
v0
.
getInputStream
())
{
try
{
result
=
ValueLong
.
get
(
IOUtils
.
copyAndClose
(
in
,
result
=
ValueLong
.
get
(
IOUtils
.
copyAndClose
(
in
,
fileOutputStream
));
fileOutputStream
));
}
finally
{
in
.
close
();
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
DbException
.
convertIOException
(
e
,
fileName
);
throw
DbException
.
convertIOException
(
e
,
fileName
);
...
...
h2/src/main/org/h2/expression/Subquery.java
浏览文件 @
0a92f254
...
@@ -33,8 +33,7 @@ public class Subquery extends Expression {
...
@@ -33,8 +33,7 @@ public class Subquery extends Expression {
@Override
@Override
public
Value
getValue
(
Session
session
)
{
public
Value
getValue
(
Session
session
)
{
query
.
setSession
(
session
);
query
.
setSession
(
session
);
ResultInterface
result
=
query
.
query
(
2
);
try
(
ResultInterface
result
=
query
.
query
(
2
))
{
try
{
int
rowcount
=
result
.
getRowCount
();
int
rowcount
=
result
.
getRowCount
();
if
(
rowcount
>
1
)
{
if
(
rowcount
>
1
)
{
throw
DbException
.
get
(
ErrorCode
.
SCALAR_SUBQUERY_CONTAINS_MORE_THAN_ONE_ROW
);
throw
DbException
.
get
(
ErrorCode
.
SCALAR_SUBQUERY_CONTAINS_MORE_THAN_ONE_ROW
);
...
@@ -52,8 +51,6 @@ public class Subquery extends Expression {
...
@@ -52,8 +51,6 @@ public class Subquery extends Expression {
}
}
}
}
return
v
;
return
v
;
}
finally
{
result
.
close
();
}
}
}
}
...
...
h2/src/main/org/h2/jdbc/JdbcBlob.java
浏览文件 @
0a92f254
...
@@ -16,13 +16,12 @@ import java.io.PipedInputStream;
...
@@ -16,13 +16,12 @@ import java.io.PipedInputStream;
import
java.io.PipedOutputStream
;
import
java.io.PipedOutputStream
;
import
java.sql.Blob
;
import
java.sql.Blob
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.message.TraceObject
;
import
org.h2.message.TraceObject
;
import
org.h2.util.Task
;
import
org.h2.util.IOUtils
;
import
org.h2.util.IOUtils
;
import
org.h2.util.Task
;
import
org.h2.value.Value
;
import
org.h2.value.Value
;
/**
/**
...
@@ -89,12 +88,9 @@ public class JdbcBlob extends TraceObject implements Blob {
...
@@ -89,12 +88,9 @@ public class JdbcBlob extends TraceObject implements Blob {
}
}
checkClosed
();
checkClosed
();
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
InputStream
in
=
value
.
getInputStream
();
try
(
InputStream
in
=
value
.
getInputStream
())
{
try
{
IOUtils
.
skipFully
(
in
,
pos
-
1
);
IOUtils
.
skipFully
(
in
,
pos
-
1
);
IOUtils
.
copy
(
in
,
out
,
length
);
IOUtils
.
copy
(
in
,
out
,
length
);
}
finally
{
in
.
close
();
}
}
return
out
.
toByteArray
();
return
out
.
toByteArray
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
h2/src/main/org/h2/jdbc/JdbcClob.java
浏览文件 @
0a92f254
...
@@ -17,7 +17,6 @@ import java.io.Writer;
...
@@ -17,7 +17,6 @@ import java.io.Writer;
import
java.sql.Clob
;
import
java.sql.Clob
;
import
java.sql.NClob
;
import
java.sql.NClob
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
...
@@ -189,12 +188,9 @@ public class JdbcClob extends TraceObject implements NClob
...
@@ -189,12 +188,9 @@ public class JdbcClob extends TraceObject implements NClob
}
}
StringWriter
writer
=
new
StringWriter
(
StringWriter
writer
=
new
StringWriter
(
Math
.
min
(
Constants
.
IO_BUFFER_SIZE
,
length
));
Math
.
min
(
Constants
.
IO_BUFFER_SIZE
,
length
));
Reader
reader
=
value
.
getReader
();
try
(
Reader
reader
=
value
.
getReader
())
{
try
{
IOUtils
.
skipFully
(
reader
,
pos
-
1
);
IOUtils
.
skipFully
(
reader
,
pos
-
1
);
IOUtils
.
copyAndCloseInput
(
reader
,
writer
,
length
);
IOUtils
.
copyAndCloseInput
(
reader
,
writer
,
length
);
}
finally
{
reader
.
close
();
}
}
return
writer
.
toString
();
return
writer
.
toString
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
h2/src/main/org/h2/jdbcx/JdbcXAConnection.java
浏览文件 @
0a92f254
...
@@ -17,14 +17,11 @@ import javax.sql.XAConnection;
...
@@ -17,14 +17,11 @@ import javax.sql.XAConnection;
import
javax.transaction.xa.XAException
;
import
javax.transaction.xa.XAException
;
import
javax.transaction.xa.XAResource
;
import
javax.transaction.xa.XAResource
;
import
javax.transaction.xa.Xid
;
import
javax.transaction.xa.Xid
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.jdbc.JdbcConnection
;
import
org.h2.jdbc.JdbcConnection
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.New
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.message.TraceObject
;
import
org.h2.message.TraceObject
;
import
org.h2.util.New
;
/**
/**
...
@@ -193,9 +190,7 @@ public class JdbcXAConnection extends TraceObject implements XAConnection,
...
@@ -193,9 +190,7 @@ public class JdbcXAConnection extends TraceObject implements XAConnection,
public
Xid
[]
recover
(
int
flag
)
throws
XAException
{
public
Xid
[]
recover
(
int
flag
)
throws
XAException
{
debugCodeCall
(
"recover"
,
quoteFlags
(
flag
));
debugCodeCall
(
"recover"
,
quoteFlags
(
flag
));
checkOpen
();
checkOpen
();
Statement
stat
=
null
;
try
(
Statement
stat
=
physicalConn
.
createStatement
())
{
try
{
stat
=
physicalConn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
"INFORMATION_SCHEMA.IN_DOUBT ORDER BY TRANSACTION"
);
"INFORMATION_SCHEMA.IN_DOUBT ORDER BY TRANSACTION"
);
ArrayList
<
Xid
>
list
=
New
.
arrayList
();
ArrayList
<
Xid
>
list
=
New
.
arrayList
();
...
@@ -216,8 +211,6 @@ public class JdbcXAConnection extends TraceObject implements XAConnection,
...
@@ -216,8 +211,6 @@ public class JdbcXAConnection extends TraceObject implements XAConnection,
XAException
xa
=
new
XAException
(
XAException
.
XAER_RMERR
);
XAException
xa
=
new
XAException
(
XAException
.
XAER_RMERR
);
xa
.
initCause
(
e
);
xa
.
initCause
(
e
);
throw
xa
;
throw
xa
;
}
finally
{
JdbcUtils
.
closeSilently
(
stat
);
}
}
}
}
...
@@ -236,15 +229,12 @@ public class JdbcXAConnection extends TraceObject implements XAConnection,
...
@@ -236,15 +229,12 @@ public class JdbcXAConnection extends TraceObject implements XAConnection,
if
(!
currentTransaction
.
equals
(
xid
))
{
if
(!
currentTransaction
.
equals
(
xid
))
{
throw
new
XAException
(
XAException
.
XAER_INVAL
);
throw
new
XAException
(
XAException
.
XAER_INVAL
);
}
}
Statement
stat
=
null
;
try
{
try
(
Statement
stat
=
physicalConn
.
createStatement
())
{
stat
=
physicalConn
.
createStatement
();
stat
.
execute
(
"PREPARE COMMIT "
+
JdbcXid
.
toString
(
xid
));
stat
.
execute
(
"PREPARE COMMIT "
+
JdbcXid
.
toString
(
xid
));
prepared
=
true
;
prepared
=
true
;
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
throw
convertException
(
e
);
throw
convertException
(
e
);
}
finally
{
JdbcUtils
.
closeSilently
(
stat
);
}
}
return
XA_OK
;
return
XA_OK
;
}
}
...
@@ -275,12 +265,8 @@ public class JdbcXAConnection extends TraceObject implements XAConnection,
...
@@ -275,12 +265,8 @@ public class JdbcXAConnection extends TraceObject implements XAConnection,
}
}
try
{
try
{
if
(
prepared
)
{
if
(
prepared
)
{
Statement
stat
=
null
;
try
(
Statement
stat
=
physicalConn
.
createStatement
())
{
try
{
stat
=
physicalConn
.
createStatement
();
stat
.
execute
(
"ROLLBACK TRANSACTION "
+
JdbcXid
.
toString
(
xid
));
stat
.
execute
(
"ROLLBACK TRANSACTION "
+
JdbcXid
.
toString
(
xid
));
}
finally
{
JdbcUtils
.
closeSilently
(
stat
);
}
}
prepared
=
false
;
prepared
=
false
;
}
else
{
}
else
{
...
@@ -355,20 +341,19 @@ public class JdbcXAConnection extends TraceObject implements XAConnection,
...
@@ -355,20 +341,19 @@ public class JdbcXAConnection extends TraceObject implements XAConnection,
if
(
isDebugEnabled
())
{
if
(
isDebugEnabled
())
{
debugCode
(
"commit("
+
JdbcXid
.
toString
(
xid
)+
", "
+
onePhase
+
");"
);
debugCode
(
"commit("
+
JdbcXid
.
toString
(
xid
)+
", "
+
onePhase
+
");"
);
}
}
Statement
stat
=
null
;
try
{
try
{
if
(
onePhase
)
{
if
(
onePhase
)
{
physicalConn
.
commit
();
physicalConn
.
commit
();
}
else
{
}
else
{
stat
=
physicalConn
.
createStatement
();
try
(
Statement
stat
=
physicalConn
.
createStatement
())
{
stat
.
execute
(
"COMMIT TRANSACTION "
+
JdbcXid
.
toString
(
xid
));
stat
.
execute
(
"COMMIT TRANSACTION "
+
JdbcXid
.
toString
(
xid
));
prepared
=
false
;
prepared
=
false
;
}
}
}
physicalConn
.
setAutoCommit
(
true
);
physicalConn
.
setAutoCommit
(
true
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
throw
convertException
(
e
);
throw
convertException
(
e
);
}
finally
{
JdbcUtils
.
closeSilently
(
stat
);
}
}
currentTransaction
=
null
;
currentTransaction
=
null
;
}
}
...
...
h2/src/main/org/h2/result/LocalResult.java
浏览文件 @
0a92f254
...
@@ -24,7 +24,7 @@ import org.h2.value.ValueArray;
...
@@ -24,7 +24,7 @@ import org.h2.value.ValueArray;
* and it is also used directly by the ResultSet class in the embedded mode.
* and it is also used directly by the ResultSet class in the embedded mode.
* If the result does not fit in memory, it is written to a temporary file.
* If the result does not fit in memory, it is written to a temporary file.
*/
*/
public
class
LocalResult
implements
ResultInterface
,
ResultTarget
{
public
class
LocalResult
implements
ResultInterface
,
ResultTarget
,
AutoCloseable
{
private
int
maxMemoryRows
;
private
int
maxMemoryRows
;
private
Session
session
;
private
Session
session
;
...
...
h2/src/main/org/h2/result/ResultInterface.java
浏览文件 @
0a92f254
...
@@ -11,7 +11,7 @@ import org.h2.value.Value;
...
@@ -11,7 +11,7 @@ import org.h2.value.Value;
* The result interface is used by the LocalResult and ResultRemote class.
* The result interface is used by the LocalResult and ResultRemote class.
* A result may contain rows, or just an update count.
* A result may contain rows, or just an update count.
*/
*/
public
interface
ResultInterface
{
public
interface
ResultInterface
extends
AutoCloseable
{
/**
/**
* Go to the beginning of the result, that means
* Go to the beginning of the result, that means
...
...
h2/src/main/org/h2/server/TcpServer.java
浏览文件 @
0a92f254
...
@@ -92,9 +92,8 @@ public class TcpServer implements Service {
...
@@ -92,9 +92,8 @@ public class TcpServer implements Service {
Connection
conn
=
Driver
.
load
().
connect
(
"jdbc:h2:"
+
Connection
conn
=
Driver
.
load
().
connect
(
"jdbc:h2:"
+
getManagementDbName
(
port
),
prop
);
getManagementDbName
(
port
),
prop
);
managementDb
=
conn
;
managementDb
=
conn
;
Statement
stat
=
null
;
try
{
try
(
Statement
stat
=
conn
.
createStatement
())
{
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE ALIAS IF NOT EXISTS STOP_SERVER FOR \""
+
stat
.
execute
(
"CREATE ALIAS IF NOT EXISTS STOP_SERVER FOR \""
+
TcpServer
.
class
.
getName
()
+
".stopServer\""
);
TcpServer
.
class
.
getName
()
+
".stopServer\""
);
stat
.
execute
(
"CREATE TABLE IF NOT EXISTS SESSIONS"
+
stat
.
execute
(
"CREATE TABLE IF NOT EXISTS SESSIONS"
+
...
@@ -104,8 +103,6 @@ public class TcpServer implements Service {
...
@@ -104,8 +103,6 @@ public class TcpServer implements Service {
"INSERT INTO SESSIONS VALUES(?, ?, ?, NOW())"
);
"INSERT INTO SESSIONS VALUES(?, ?, ?, NOW())"
);
managementDbRemove
=
conn
.
prepareStatement
(
managementDbRemove
=
conn
.
prepareStatement
(
"DELETE FROM SESSIONS WHERE ID=?"
);
"DELETE FROM SESSIONS WHERE ID=?"
);
}
finally
{
JdbcUtils
.
closeSilently
(
stat
);
}
}
SERVERS
.
put
(
port
,
this
);
SERVERS
.
put
(
port
,
this
);
}
}
...
...
h2/src/main/org/h2/server/pg/PgServerThread.java
浏览文件 @
0a92f254
...
@@ -28,7 +28,6 @@ import java.sql.Types;
...
@@ -28,7 +28,6 @@ import java.sql.Types;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Properties
;
import
java.util.Properties
;
import
org.h2.command.CommandInterface
;
import
org.h2.command.CommandInterface
;
import
org.h2.engine.ConnectionInfo
;
import
org.h2.engine.ConnectionInfo
;
import
org.h2.engine.SysProperties
;
import
org.h2.engine.SysProperties
;
...
@@ -37,7 +36,6 @@ import org.h2.jdbc.JdbcPreparedStatement;
...
@@ -37,7 +36,6 @@ import org.h2.jdbc.JdbcPreparedStatement;
import
org.h2.jdbc.JdbcStatement
;
import
org.h2.jdbc.JdbcStatement
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.mvstore.DataUtils
;
import
org.h2.mvstore.DataUtils
;
import
org.h2.util.IOUtils
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.ScriptReader
;
import
org.h2.util.ScriptReader
;
...
@@ -827,10 +825,8 @@ public class PgServerThread implements Runnable {
...
@@ -827,10 +825,8 @@ public class PgServerThread implements Runnable {
}
}
private
static
void
installPgCatalog
(
Statement
stat
)
throws
SQLException
{
private
static
void
installPgCatalog
(
Statement
stat
)
throws
SQLException
{
Reader
r
=
null
;
try
(
Reader
r
=
new
InputStreamReader
(
new
ByteArrayInputStream
(
Utils
try
{
.
getResource
(
"/org/h2/server/pg/pg_catalog.sql"
))))
{
r
=
new
InputStreamReader
(
new
ByteArrayInputStream
(
Utils
.
getResource
(
"/org/h2/server/pg/pg_catalog.sql"
)));
ScriptReader
reader
=
new
ScriptReader
(
r
);
ScriptReader
reader
=
new
ScriptReader
(
r
);
while
(
true
)
{
while
(
true
)
{
String
sql
=
reader
.
readStatement
();
String
sql
=
reader
.
readStatement
();
...
@@ -842,8 +838,6 @@ public class PgServerThread implements Runnable {
...
@@ -842,8 +838,6 @@ public class PgServerThread implements Runnable {
reader
.
close
();
reader
.
close
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
DbException
.
convertIOException
(
e
,
"Can not read pg_catalog resource"
);
throw
DbException
.
convertIOException
(
e
,
"Can not read pg_catalog resource"
);
}
finally
{
IOUtils
.
closeSilently
(
r
);
}
}
}
}
...
...
h2/src/main/org/h2/server/web/WebApp.java
浏览文件 @
0a92f254
...
@@ -32,7 +32,6 @@ import java.util.Locale;
...
@@ -32,7 +32,6 @@ import java.util.Locale;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.Properties
;
import
java.util.Random
;
import
java.util.Random
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.bnf.Bnf
;
import
org.h2.bnf.Bnf
;
import
org.h2.bnf.context.DbColumn
;
import
org.h2.bnf.context.DbColumn
;
...
@@ -660,10 +659,9 @@ public class WebApp {
...
@@ -660,10 +659,9 @@ public class WebApp {
treeIndex
=
addColumns
(
mainSchema
,
view
,
buff
,
treeIndex
=
addColumns
(
mainSchema
,
view
,
buff
,
treeIndex
,
notManyTables
,
columnsBuffer
);
treeIndex
,
notManyTables
,
columnsBuffer
);
if
(
schema
.
getContents
().
isH2
())
{
if
(
schema
.
getContents
().
isH2
())
{
PreparedStatement
prep
=
null
;
try
{
try
(
PreparedStatement
prep
=
conn
.
prepareStatement
(
"SELECT * FROM "
+
prep
=
conn
.
prepareStatement
(
"SELECT * FROM "
+
"INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME=?"
))
{
"INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME=?"
);
prep
.
setString
(
1
,
view
.
getName
());
prep
.
setString
(
1
,
view
.
getName
());
ResultSet
rs
=
prep
.
executeQuery
();
ResultSet
rs
=
prep
.
executeQuery
();
if
(
rs
.
next
())
{
if
(
rs
.
next
())
{
...
@@ -675,8 +673,6 @@ public class WebApp {
...
@@ -675,8 +673,6 @@ public class WebApp {
treeIndex
++;
treeIndex
++;
}
}
rs
.
close
();
rs
.
close
();
}
finally
{
JdbcUtils
.
closeSilently
(
prep
);
}
}
}
}
buff
.
append
(
"addTable('"
+
buff
.
append
(
"addTable('"
+
...
@@ -717,9 +713,7 @@ public class WebApp {
...
@@ -717,9 +713,7 @@ public class WebApp {
treeIndex
=
addTablesAndViews
(
schema
,
false
,
buff
,
treeIndex
);
treeIndex
=
addTablesAndViews
(
schema
,
false
,
buff
,
treeIndex
);
}
}
if
(
isH2
)
{
if
(
isH2
)
{
Statement
stat
=
null
;
try
(
Statement
stat
=
conn
.
createStatement
())
{
try
{
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
"INFORMATION_SCHEMA.SEQUENCES ORDER BY SEQUENCE_NAME"
);
"INFORMATION_SCHEMA.SEQUENCES ORDER BY SEQUENCE_NAME"
);
for
(
int
i
=
0
;
rs
.
next
();
i
++)
{
for
(
int
i
=
0
;
rs
.
next
();
i
++)
{
...
@@ -773,8 +767,6 @@ public class WebApp {
...
@@ -773,8 +767,6 @@ public class WebApp {
}
}
}
}
rs
.
close
();
rs
.
close
();
}
finally
{
JdbcUtils
.
closeSilently
(
stat
);
}
}
}
}
DatabaseMetaData
meta
=
session
.
getMetaData
();
DatabaseMetaData
meta
=
session
.
getMetaData
();
...
...
h2/src/main/org/h2/store/FileLister.java
浏览文件 @
0a92f254
...
@@ -5,12 +5,10 @@
...
@@ -5,12 +5,10 @@
*/
*/
package
org
.
h2
.
store
;
package
org
.
h2
.
store
;
import
java.io.IOException
;
import
java.nio.channels.FileChannel
;
import
java.nio.channels.FileChannel
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
...
@@ -51,23 +49,13 @@ public class FileLister {
...
@@ -51,23 +49,13 @@ public class FileLister {
message
).
getSQLException
();
message
).
getSQLException
();
}
}
}
else
if
(
fileName
.
endsWith
(
Constants
.
SUFFIX_MV_FILE
))
{
}
else
if
(
fileName
.
endsWith
(
Constants
.
SUFFIX_MV_FILE
))
{
FileChannel
f
=
null
;
try
(
FileChannel
f
=
FilePath
.
get
(
fileName
).
open
(
"r"
))
{
try
{
f
=
FilePath
.
get
(
fileName
).
open
(
"r"
);
java
.
nio
.
channels
.
FileLock
lock
=
f
.
tryLock
(
0
,
Long
.
MAX_VALUE
,
true
);
java
.
nio
.
channels
.
FileLock
lock
=
f
.
tryLock
(
0
,
Long
.
MAX_VALUE
,
true
);
lock
.
release
();
lock
.
release
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
DbException
.
get
(
throw
DbException
.
get
(
ErrorCode
.
CANNOT_CHANGE_SETTING_WHEN_OPEN_1
,
e
,
ErrorCode
.
CANNOT_CHANGE_SETTING_WHEN_OPEN_1
,
e
,
message
).
getSQLException
();
message
).
getSQLException
();
}
finally
{
if
(
f
!=
null
)
{
try
{
f
.
close
();
}
catch
(
IOException
e
)
{
// ignore
}
}
}
}
}
}
}
}
...
...
h2/src/main/org/h2/store/FileLock.java
浏览文件 @
0a92f254
...
@@ -210,11 +210,8 @@ public class FileLock implements Runnable {
...
@@ -210,11 +210,8 @@ public class FileLock implements Runnable {
*/
*/
public
Properties
save
()
{
public
Properties
save
()
{
try
{
try
{
OutputStream
out
=
FileUtils
.
newOutputStream
(
fileName
,
false
);
try
(
OutputStream
out
=
FileUtils
.
newOutputStream
(
fileName
,
false
))
{
try
{
properties
.
store
(
out
,
MAGIC
);
properties
.
store
(
out
,
MAGIC
);
}
finally
{
out
.
close
();
}
}
lastWrite
=
FileUtils
.
lastModified
(
fileName
);
lastWrite
=
FileUtils
.
lastModified
(
fileName
);
if
(
trace
.
isDebugEnabled
())
{
if
(
trace
.
isDebugEnabled
())
{
...
...
h2/src/main/org/h2/store/fs/FilePathZip.java
浏览文件 @
0a92f254
...
@@ -55,11 +55,8 @@ public class FilePathZip extends FilePath {
...
@@ -55,11 +55,8 @@ public class FilePathZip extends FilePath {
if
(
entryName
.
length
()
==
0
)
{
if
(
entryName
.
length
()
==
0
)
{
return
true
;
return
true
;
}
}
ZipFile
file
=
openZipFile
();
try
(
ZipFile
file
=
openZipFile
())
{
try
{
return
file
.
getEntry
(
entryName
)
!=
null
;
return
file
.
getEntry
(
entryName
)
!=
null
;
}
finally
{
file
.
close
();
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
return
false
;
return
false
;
...
@@ -95,8 +92,7 @@ public class FilePathZip extends FilePath {
...
@@ -95,8 +92,7 @@ public class FilePathZip extends FilePath {
if
(
entryName
.
length
()
==
0
)
{
if
(
entryName
.
length
()
==
0
)
{
return
true
;
return
true
;
}
}
ZipFile
file
=
openZipFile
();
try
(
ZipFile
file
=
openZipFile
())
{
try
{
Enumeration
<?
extends
ZipEntry
>
en
=
file
.
entries
();
Enumeration
<?
extends
ZipEntry
>
en
=
file
.
entries
();
while
(
en
.
hasMoreElements
())
{
while
(
en
.
hasMoreElements
())
{
ZipEntry
entry
=
en
.
nextElement
();
ZipEntry
entry
=
en
.
nextElement
();
...
@@ -111,8 +107,6 @@ public class FilePathZip extends FilePath {
...
@@ -111,8 +107,6 @@ public class FilePathZip extends FilePath {
}
}
}
}
}
}
}
finally
{
file
.
close
();
}
}
return
false
;
return
false
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
@@ -133,12 +127,9 @@ public class FilePathZip extends FilePath {
...
@@ -133,12 +127,9 @@ public class FilePathZip extends FilePath {
@Override
@Override
public
long
size
()
{
public
long
size
()
{
try
{
try
{
ZipFile
file
=
openZipFile
();
try
(
ZipFile
file
=
openZipFile
())
{
try
{
ZipEntry
entry
=
file
.
getEntry
(
getEntryName
());
ZipEntry
entry
=
file
.
getEntry
(
getEntryName
());
return
entry
==
null
?
0
:
entry
.
getSize
();
return
entry
==
null
?
0
:
entry
.
getSize
();
}
finally
{
file
.
close
();
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
return
0
;
return
0
;
...
@@ -156,8 +147,7 @@ public class FilePathZip extends FilePath {
...
@@ -156,8 +147,7 @@ public class FilePathZip extends FilePath {
if
(!
path
.
endsWith
(
"/"
))
{
if
(!
path
.
endsWith
(
"/"
))
{
path
+=
"/"
;
path
+=
"/"
;
}
}
ZipFile
file
=
openZipFile
();
try
(
ZipFile
file
=
openZipFile
())
{
try
{
String
dirName
=
getEntryName
();
String
dirName
=
getEntryName
();
String
prefix
=
path
.
substring
(
0
,
path
.
length
()
-
dirName
.
length
());
String
prefix
=
path
.
substring
(
0
,
path
.
length
()
-
dirName
.
length
());
Enumeration
<?
extends
ZipEntry
>
en
=
file
.
entries
();
Enumeration
<?
extends
ZipEntry
>
en
=
file
.
entries
();
...
@@ -175,8 +165,6 @@ public class FilePathZip extends FilePath {
...
@@ -175,8 +165,6 @@ public class FilePathZip extends FilePath {
list
.
add
(
getPath
(
prefix
+
name
));
list
.
add
(
getPath
(
prefix
+
name
));
}
}
}
}
}
finally
{
file
.
close
();
}
}
return
list
;
return
list
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
...
h2/src/main/org/h2/table/TableLink.java
浏览文件 @
0a92f254
...
@@ -15,7 +15,6 @@ import java.sql.Types;
...
@@ -15,7 +15,6 @@ import java.sql.Types;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.command.Prepared
;
import
org.h2.command.Prepared
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
...
@@ -28,7 +27,6 @@ import org.h2.message.DbException;
...
@@ -28,7 +27,6 @@ import org.h2.message.DbException;
import
org.h2.result.Row
;
import
org.h2.result.Row
;
import
org.h2.result.RowList
;
import
org.h2.result.RowList
;
import
org.h2.schema.Schema
;
import
org.h2.schema.Schema
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.New
;
import
org.h2.util.New
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StatementBuilder
;
...
@@ -169,9 +167,8 @@ public class TableLink extends Table {
...
@@ -169,9 +167,8 @@ public class TableLink extends Table {
qualifiedTableName
=
originalTable
;
qualifiedTableName
=
originalTable
;
}
}
// check if the table is accessible
// check if the table is accessible
Statement
stat
=
null
;
try
{
try
(
Statement
stat
=
conn
.
getConnection
().
createStatement
())
{
stat
=
conn
.
getConnection
().
createStatement
();
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
qualifiedTableName
+
" T WHERE 1=0"
);
qualifiedTableName
+
" T WHERE 1=0"
);
if
(
columnList
.
size
()
==
0
)
{
if
(
columnList
.
size
()
==
0
)
{
...
@@ -197,8 +194,6 @@ public class TableLink extends Table {
...
@@ -197,8 +194,6 @@ public class TableLink extends Table {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
DbException
.
get
(
ErrorCode
.
TABLE_OR_VIEW_NOT_FOUND_1
,
e
,
throw
DbException
.
get
(
ErrorCode
.
TABLE_OR_VIEW_NOT_FOUND_1
,
e
,
originalTable
+
"("
+
e
.
toString
()
+
")"
);
originalTable
+
"("
+
e
.
toString
()
+
")"
);
}
finally
{
JdbcUtils
.
closeSilently
(
stat
);
}
}
Column
[]
cols
=
new
Column
[
columnList
.
size
()];
Column
[]
cols
=
new
Column
[
columnList
.
size
()];
columnList
.
toArray
(
cols
);
columnList
.
toArray
(
cols
);
...
...
h2/src/main/org/h2/tools/Restore.java
浏览文件 @
0a92f254
...
@@ -11,7 +11,6 @@ import java.io.OutputStream;
...
@@ -11,7 +11,6 @@ import java.io.OutputStream;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipInputStream
;
import
java.util.zip.ZipInputStream
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.engine.SysProperties
;
import
org.h2.engine.SysProperties
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
...
@@ -74,9 +73,8 @@ public class Restore extends Tool {
...
@@ -74,9 +73,8 @@ public class Restore extends Tool {
private
static
String
getOriginalDbName
(
String
fileName
,
String
db
)
private
static
String
getOriginalDbName
(
String
fileName
,
String
db
)
throws
IOException
{
throws
IOException
{
InputStream
in
=
null
;
try
{
try
(
InputStream
in
=
FileUtils
.
newInputStream
(
fileName
))
{
in
=
FileUtils
.
newInputStream
(
fileName
);
ZipInputStream
zipIn
=
new
ZipInputStream
(
in
);
ZipInputStream
zipIn
=
new
ZipInputStream
(
in
);
String
originalDbName
=
null
;
String
originalDbName
=
null
;
boolean
multiple
=
false
;
boolean
multiple
=
false
;
...
@@ -108,8 +106,6 @@ public class Restore extends Tool {
...
@@ -108,8 +106,6 @@ public class Restore extends Tool {
throw
new
IOException
(
"Multiple databases found, but not "
+
db
);
throw
new
IOException
(
"Multiple databases found, but not "
+
db
);
}
}
return
originalDbName
;
return
originalDbName
;
}
finally
{
IOUtils
.
closeSilently
(
in
);
}
}
}
}
...
...
h2/src/main/org/h2/tools/Script.java
浏览文件 @
0a92f254
...
@@ -9,7 +9,6 @@ import java.sql.Connection;
...
@@ -9,7 +9,6 @@ import java.sql.Connection;
import
java.sql.DriverManager
;
import
java.sql.DriverManager
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.StringUtils
;
import
org.h2.util.StringUtils
;
import
org.h2.util.Tool
;
import
org.h2.util.Tool
;
...
@@ -134,13 +133,10 @@ public class Script extends Tool {
...
@@ -134,13 +133,10 @@ public class Script extends Tool {
*/
*/
public
static
void
process
(
Connection
conn
,
public
static
void
process
(
Connection
conn
,
String
fileName
,
String
options1
,
String
options2
)
throws
SQLException
{
String
fileName
,
String
options1
,
String
options2
)
throws
SQLException
{
Statement
stat
=
null
;
try
{
try
(
Statement
stat
=
conn
.
createStatement
())
{
stat
=
conn
.
createStatement
();
String
sql
=
"SCRIPT "
+
options1
+
" TO '"
+
fileName
+
"' "
+
options2
;
String
sql
=
"SCRIPT "
+
options1
+
" TO '"
+
fileName
+
"' "
+
options2
;
stat
.
execute
(
sql
);
stat
.
execute
(
sql
);
}
finally
{
JdbcUtils
.
closeSilently
(
stat
);
}
}
}
}
...
...
h2/src/main/org/h2/util/SortedProperties.java
浏览文件 @
0a92f254
...
@@ -17,10 +17,10 @@ import java.io.PrintWriter;
...
@@ -17,10 +17,10 @@ import java.io.PrintWriter;
import
java.io.Writer
;
import
java.io.Writer
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Enumeration
;
import
java.util.Enumeration
;
import
java.util.Map.Entry
;
import
java.util.Properties
;
import
java.util.Properties
;
import
java.util.TreeMap
;
import
java.util.TreeMap
;
import
java.util.Vector
;
import
java.util.Vector
;
import
java.util.Map.Entry
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
/**
/**
...
@@ -88,14 +88,8 @@ public class SortedProperties extends Properties {
...
@@ -88,14 +88,8 @@ public class SortedProperties extends Properties {
throws
IOException
{
throws
IOException
{
SortedProperties
prop
=
new
SortedProperties
();
SortedProperties
prop
=
new
SortedProperties
();
if
(
FileUtils
.
exists
(
fileName
))
{
if
(
FileUtils
.
exists
(
fileName
))
{
InputStream
in
=
null
;
try
(
InputStream
in
=
FileUtils
.
newInputStream
(
fileName
))
{
try
{
in
=
FileUtils
.
newInputStream
(
fileName
);
prop
.
load
(
in
);
prop
.
load
(
in
);
}
finally
{
if
(
in
!=
null
)
{
in
.
close
();
}
}
}
}
}
return
prop
;
return
prop
;
...
...
h2/src/main/org/h2/util/SourceCompiler.java
浏览文件 @
0a92f254
...
@@ -282,7 +282,7 @@ public class SourceCompiler {
...
@@ -282,7 +282,7 @@ public class SourceCompiler {
.
getStandardFileManager
(
null
,
null
,
null
));
.
getStandardFileManager
(
null
,
null
,
null
));
ArrayList
<
JavaFileObject
>
compilationUnits
=
new
ArrayList
<
JavaFileObject
>();
ArrayList
<
JavaFileObject
>
compilationUnits
=
new
ArrayList
<
JavaFileObject
>();
compilationUnits
.
add
(
new
StringJavaFileObject
(
fullClassName
,
source
));
compilationUnits
.
add
(
new
StringJavaFileObject
(
fullClassName
,
source
));
// can
not concurrently compile
// cannot concurrently compile
synchronized
(
JAVA_COMPILER
)
{
synchronized
(
JAVA_COMPILER
)
{
JAVA_COMPILER
.
getTask
(
writer
,
fileManager
,
null
,
null
,
JAVA_COMPILER
.
getTask
(
writer
,
fileManager
,
null
,
null
,
null
,
compilationUnits
).
call
();
null
,
compilationUnits
).
call
();
...
...
h2/src/main/org/h2/util/Utils.java
浏览文件 @
0a92f254
...
@@ -478,8 +478,8 @@ public class Utils {
...
@@ -478,8 +478,8 @@ public class Utils {
}
}
return
IOUtils
.
readBytesAndClose
(
in
,
0
);
return
IOUtils
.
readBytesAndClose
(
in
,
0
);
}
}
ZipInputStream
zipIn
=
new
ZipInputStream
(
in
);
try
{
try
(
ZipInputStream
zipIn
=
new
ZipInputStream
(
in
))
{
while
(
true
)
{
while
(
true
)
{
ZipEntry
entry
=
zipIn
.
getNextEntry
();
ZipEntry
entry
=
zipIn
.
getNextEntry
();
if
(
entry
==
null
)
{
if
(
entry
==
null
)
{
...
@@ -500,8 +500,6 @@ public class Utils {
...
@@ -500,8 +500,6 @@ public class Utils {
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
// if this happens we have a real problem
// if this happens we have a real problem
e
.
printStackTrace
();
e
.
printStackTrace
();
}
finally
{
zipIn
.
close
();
}
}
return
null
;
return
null
;
}
}
...
...
h2/src/main/org/h2/value/ValueLob.java
浏览文件 @
0a92f254
...
@@ -13,7 +13,6 @@ import java.io.InputStream;
...
@@ -13,7 +13,6 @@ import java.io.InputStream;
import
java.io.Reader
;
import
java.io.Reader
;
import
java.sql.PreparedStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.engine.SysProperties
;
import
org.h2.engine.SysProperties
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
...
@@ -222,9 +221,8 @@ public class ValueLob extends Value {
...
@@ -222,9 +221,8 @@ public class ValueLob extends Value {
private
void
createFromReader
(
char
[]
buff
,
int
len
,
Reader
in
,
private
void
createFromReader
(
char
[]
buff
,
int
len
,
Reader
in
,
long
remaining
,
DataHandler
h
)
throws
IOException
{
long
remaining
,
DataHandler
h
)
throws
IOException
{
FileStoreOutputStream
out
=
initLarge
(
h
);
try
(
FileStoreOutputStream
out
=
initLarge
(
h
))
{
boolean
compress
=
h
.
getLobCompressionAlgorithm
(
Value
.
CLOB
)
!=
null
;
boolean
compress
=
h
.
getLobCompressionAlgorithm
(
Value
.
CLOB
)
!=
null
;
try
{
while
(
true
)
{
while
(
true
)
{
precision
+=
len
;
precision
+=
len
;
byte
[]
b
=
new
String
(
buff
,
0
,
len
).
getBytes
(
Constants
.
UTF8
);
byte
[]
b
=
new
String
(
buff
,
0
,
len
).
getBytes
(
Constants
.
UTF8
);
...
@@ -239,8 +237,6 @@ public class ValueLob extends Value {
...
@@ -239,8 +237,6 @@ public class ValueLob extends Value {
break
;
break
;
}
}
}
}
}
finally
{
out
.
close
();
}
}
}
}
...
@@ -421,9 +417,8 @@ public class ValueLob extends Value {
...
@@ -421,9 +417,8 @@ public class ValueLob extends Value {
private
void
createFromStream
(
byte
[]
buff
,
int
len
,
InputStream
in
,
private
void
createFromStream
(
byte
[]
buff
,
int
len
,
InputStream
in
,
long
remaining
,
DataHandler
h
)
throws
IOException
{
long
remaining
,
DataHandler
h
)
throws
IOException
{
FileStoreOutputStream
out
=
initLarge
(
h
);
try
(
FileStoreOutputStream
out
=
initLarge
(
h
))
{
boolean
compress
=
h
.
getLobCompressionAlgorithm
(
Value
.
BLOB
)
!=
null
;
boolean
compress
=
h
.
getLobCompressionAlgorithm
(
Value
.
BLOB
)
!=
null
;
try
{
while
(
true
)
{
while
(
true
)
{
precision
+=
len
;
precision
+=
len
;
out
.
write
(
buff
,
0
,
len
);
out
.
write
(
buff
,
0
,
len
);
...
@@ -437,8 +432,6 @@ public class ValueLob extends Value {
...
@@ -437,8 +432,6 @@ public class ValueLob extends Value {
break
;
break
;
}
}
}
}
}
finally
{
out
.
close
();
}
}
}
}
...
...
h2/src/main/org/h2/value/ValueLobDb.java
浏览文件 @
0a92f254
...
@@ -13,7 +13,6 @@ import java.io.InputStream;
...
@@ -13,7 +13,6 @@ import java.io.InputStream;
import
java.io.Reader
;
import
java.io.Reader
;
import
java.sql.PreparedStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.engine.SysProperties
;
import
org.h2.engine.SysProperties
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
...
@@ -93,9 +92,9 @@ public class ValueLobDb extends Value implements Value.ValueClob,
...
@@ -93,9 +92,9 @@ public class ValueLobDb extends Value implements Value.ValueClob,
this
.
fileName
=
createTempLobFileName
(
handler
);
this
.
fileName
=
createTempLobFileName
(
handler
);
this
.
tempFile
=
this
.
handler
.
openFile
(
fileName
,
"rw"
,
false
);
this
.
tempFile
=
this
.
handler
.
openFile
(
fileName
,
"rw"
,
false
);
this
.
tempFile
.
autoDelete
();
this
.
tempFile
.
autoDelete
();
FileStoreOutputStream
out
=
new
FileStoreOutputStream
(
tempFile
,
null
,
null
);
long
tmpPrecision
=
0
;
long
tmpPrecision
=
0
;
try
{
try
(
FileStoreOutputStream
out
=
new
FileStoreOutputStream
(
tempFile
,
null
,
null
))
{
char
[]
buff
=
new
char
[
Constants
.
IO_BUFFER_SIZE
];
char
[]
buff
=
new
char
[
Constants
.
IO_BUFFER_SIZE
];
while
(
true
)
{
while
(
true
)
{
int
len
=
getBufferSize
(
this
.
handler
,
false
,
remaining
);
int
len
=
getBufferSize
(
this
.
handler
,
false
,
remaining
);
...
@@ -107,8 +106,6 @@ public class ValueLobDb extends Value implements Value.ValueClob,
...
@@ -107,8 +106,6 @@ public class ValueLobDb extends Value implements Value.ValueClob,
out
.
write
(
data
);
out
.
write
(
data
);
tmpPrecision
+=
len
;
tmpPrecision
+=
len
;
}
}
}
finally
{
out
.
close
();
}
}
this
.
precision
=
tmpPrecision
;
this
.
precision
=
tmpPrecision
;
}
}
...
...
h2/src/test/org/h2/samples/FileFunctions.java
浏览文件 @
0a92f254
...
@@ -80,13 +80,10 @@ public class FileFunctions {
...
@@ -80,13 +80,10 @@ public class FileFunctions {
* @return the byte array
* @return the byte array
*/
*/
public
static
byte
[]
readFile
(
String
fileName
)
throws
IOException
{
public
static
byte
[]
readFile
(
String
fileName
)
throws
IOException
{
RandomAccessFile
file
=
new
RandomAccessFile
(
fileName
,
"r"
);
try
(
RandomAccessFile
file
=
new
RandomAccessFile
(
fileName
,
"r"
))
{
try
{
byte
[]
buff
=
new
byte
[(
int
)
file
.
length
()];
byte
[]
buff
=
new
byte
[(
int
)
file
.
length
()];
file
.
readFully
(
buff
);
file
.
readFully
(
buff
);
return
buff
;
return
buff
;
}
finally
{
file
.
close
();
}
}
}
}
}
}
h2/src/test/org/h2/test/bench/Database.java
浏览文件 @
0a92f254
...
@@ -21,7 +21,6 @@ import java.util.StringTokenizer;
...
@@ -21,7 +21,6 @@ import java.util.StringTokenizer;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.tools.Server
;
import
org.h2.tools.Server
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.StringUtils
;
import
org.h2.util.StringUtils
;
/**
/**
...
@@ -186,26 +185,18 @@ class Database {
...
@@ -186,26 +185,18 @@ class Database {
Connection
newConn
=
DriverManager
.
getConnection
(
url
,
user
,
password
);
Connection
newConn
=
DriverManager
.
getConnection
(
url
,
user
,
password
);
if
(
url
.
startsWith
(
"jdbc:derby:"
))
{
if
(
url
.
startsWith
(
"jdbc:derby:"
))
{
// Derby: use higher cache size
// Derby: use higher cache size
Statement
s
=
null
;
try
(
Statement
s
=
newConn
.
createStatement
())
{
try
{
s
=
newConn
.
createStatement
();
// stat.execute("CALL
// stat.execute("CALL
// SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(
// SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(
// 'derby.storage.pageCacheSize', '64')");
// 'derby.storage.pageCacheSize', '64')");
// stat.execute("CALL
// stat.execute("CALL
// SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(
// SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(
// 'derby.storage.pageSize', '8192')");
// 'derby.storage.pageSize', '8192')");
}
finally
{
JdbcUtils
.
closeSilently
(
s
);
}
}
}
else
if
(
url
.
startsWith
(
"jdbc:hsqldb:"
))
{
}
else
if
(
url
.
startsWith
(
"jdbc:hsqldb:"
))
{
// HSQLDB: use a WRITE_DELAY of 1 second
// HSQLDB: use a WRITE_DELAY of 1 second
Statement
s
=
null
;
try
(
Statement
s
=
newConn
.
createStatement
()){
try
{
s
=
newConn
.
createStatement
();
s
.
execute
(
"SET WRITE_DELAY 1"
);
s
.
execute
(
"SET WRITE_DELAY 1"
);
}
finally
{
JdbcUtils
.
closeSilently
(
s
);
}
}
}
}
return
newConn
;
return
newConn
;
...
...
h2/src/test/org/h2/test/coverage/Profile.java
浏览文件 @
0a92f254
...
@@ -29,9 +29,7 @@ public class Profile extends Thread {
...
@@ -29,9 +29,7 @@ public class Profile extends Thread {
private
BufferedWriter
trace
;
private
BufferedWriter
trace
;
private
Profile
()
{
private
Profile
()
{
LineNumberReader
r
=
null
;
try
(
LineNumberReader
r
=
new
LineNumberReader
(
new
FileReader
(
"profile.txt"
)))
{
try
{
r
=
new
LineNumberReader
(
new
FileReader
(
"profile.txt"
));
while
(
r
.
readLine
()
!=
null
)
{
while
(
r
.
readLine
()
!=
null
)
{
// nothing - just count lines
// nothing - just count lines
}
}
...
@@ -43,8 +41,6 @@ public class Profile extends Thread {
...
@@ -43,8 +41,6 @@ public class Profile extends Thread {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
System
.
exit
(
1
);
System
.
exit
(
1
);
}
finally
{
IOUtils
.
closeSilently
(
r
);
}
}
}
}
...
@@ -195,9 +191,8 @@ public class Profile extends Thread {
...
@@ -195,9 +191,8 @@ public class Profile extends Thread {
list
[
bigIndex
]
=
-(
big
+
1
);
list
[
bigIndex
]
=
-(
big
+
1
);
index
[
i
]
=
bigIndex
;
index
[
i
]
=
bigIndex
;
}
}
LineNumberReader
r
=
null
;
try
{
try
(
LineNumberReader
r
=
new
LineNumberReader
(
new
FileReader
(
"profile.txt"
)))
{
r
=
new
LineNumberReader
(
new
FileReader
(
"profile.txt"
));
for
(
int
i
=
0
;
i
<
maxIndex
;
i
++)
{
for
(
int
i
=
0
;
i
<
maxIndex
;
i
++)
{
String
line
=
r
.
readLine
();
String
line
=
r
.
readLine
();
int
k
=
list
[
i
];
int
k
=
list
[
i
];
...
@@ -215,8 +210,6 @@ public class Profile extends Thread {
...
@@ -215,8 +210,6 @@ public class Profile extends Thread {
for
(
int
i
=
0
;
i
<
max
;
i
++)
{
for
(
int
i
=
0
;
i
<
max
;
i
++)
{
print
(
text
[
i
]);
print
(
text
[
i
]);
}
}
}
finally
{
IOUtils
.
closeSilently
(
r
);
}
}
}
}
...
...
h2/src/test/org/h2/test/db/TestLinkedTable.java
浏览文件 @
0a92f254
...
@@ -14,7 +14,6 @@ import java.sql.ResultSetMetaData;
...
@@ -14,7 +14,6 @@ import java.sql.ResultSetMetaData;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
...
@@ -714,12 +713,9 @@ public class TestLinkedTable extends TestBase {
...
@@ -714,12 +713,9 @@ public class TestLinkedTable extends TestBase {
String
sql
=
"CREATE LINKED TABLE T(NULL, "
+
String
sql
=
"CREATE LINKED TABLE T(NULL, "
+
"'jdbc:h2:mem:one', 'sa', 'sa', 'TEST') READONLY"
;
"'jdbc:h2:mem:one', 'sa', 'sa', 'TEST') READONLY"
;
sb
.
execute
(
sql
);
sb
.
execute
(
sql
);
ResultSet
rs
=
sb
.
executeQuery
(
"SELECT * FROM T"
);
try
(
ResultSet
rs
=
sb
.
executeQuery
(
"SELECT * FROM T"
))
{
try
{
assertTrue
(
rs
.
next
());
assertTrue
(
rs
.
next
());
assertEquals
(
"POINT (1 1)"
,
rs
.
getString
(
"THE_GEOM"
));
assertEquals
(
"POINT (1 1)"
,
rs
.
getString
(
"THE_GEOM"
));
}
finally
{
rs
.
close
();
}
}
sb
.
execute
(
"DROP TABLE T"
);
sb
.
execute
(
"DROP TABLE T"
);
ca
.
close
();
ca
.
close
();
...
...
h2/src/test/org/h2/test/db/TestListener.java
浏览文件 @
0a92f254
...
@@ -10,10 +10,8 @@ import java.sql.DriverManager;
...
@@ -10,10 +10,8 @@ import java.sql.DriverManager;
import
java.sql.PreparedStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
org.h2.api.DatabaseEventListener
;
import
org.h2.api.DatabaseEventListener
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.util.JdbcUtils
;
/**
/**
* Tests the DatabaseEventListener.
* Tests the DatabaseEventListener.
...
@@ -112,15 +110,12 @@ public class TestListener extends TestBase implements DatabaseEventListener {
...
@@ -112,15 +110,12 @@ public class TestListener extends TestBase implements DatabaseEventListener {
if
(
databaseUrl
.
toUpperCase
().
contains
(
"CIPHER"
))
{
if
(
databaseUrl
.
toUpperCase
().
contains
(
"CIPHER"
))
{
return
;
return
;
}
}
Connection
conn
=
null
;
try
{
try
(
Connection
conn
=
DriverManager
.
getConnection
(
databaseUrl
,
getUser
(),
getPassword
()))
{
conn
=
DriverManager
.
getConnection
(
databaseUrl
,
getUser
(),
getPassword
());
conn
.
createStatement
().
execute
(
"DROP TABLE TEST2"
);
conn
.
createStatement
().
execute
(
"DROP TABLE TEST2"
);
conn
.
close
();
conn
.
close
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
finally
{
JdbcUtils
.
closeSilently
(
conn
);
}
}
}
}
...
@@ -134,15 +129,12 @@ public class TestListener extends TestBase implements DatabaseEventListener {
...
@@ -134,15 +129,12 @@ public class TestListener extends TestBase implements DatabaseEventListener {
if
(
databaseUrl
.
toUpperCase
().
contains
(
"CIPHER"
))
{
if
(
databaseUrl
.
toUpperCase
().
contains
(
"CIPHER"
))
{
return
;
return
;
}
}
Connection
conn
=
null
;
try
{
try
(
Connection
conn
=
DriverManager
.
getConnection
(
databaseUrl
,
getUser
(),
getPassword
()))
{
conn
=
DriverManager
.
getConnection
(
databaseUrl
,
getUser
(),
getPassword
());
conn
.
createStatement
().
execute
(
"CREATE TABLE IF NOT EXISTS TEST2(ID INT)"
);
conn
.
createStatement
().
execute
(
"CREATE TABLE IF NOT EXISTS TEST2(ID INT)"
);
conn
.
close
();
conn
.
close
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
finally
{
JdbcUtils
.
closeSilently
(
conn
);
}
}
}
}
...
...
h2/src/test/org/h2/test/db/TestMultiThread.java
浏览文件 @
0a92f254
...
@@ -81,16 +81,13 @@ public class TestMultiThread extends TestBase implements Runnable {
...
@@ -81,16 +81,13 @@ public class TestMultiThread extends TestBase implements Runnable {
Task
t
=
new
Task
()
{
Task
t
=
new
Task
()
{
@Override
@Override
public
void
call
()
throws
Exception
{
public
void
call
()
throws
Exception
{
Connection
c2
=
getConnection
(
url
);
try
(
Connection
c2
=
getConnection
(
url
))
{
Statement
stat
=
c2
.
createStatement
();
Statement
stat
=
c2
.
createStatement
();
try
{
for
(
int
i
=
0
;
!
stop
;
i
++)
{
for
(
int
i
=
0
;
!
stop
;
i
++)
{
stat
.
execute
(
"create table test"
+
x
+
"_"
+
i
);
stat
.
execute
(
"create table test"
+
x
+
"_"
+
i
);
c2
.
getMetaData
().
getTables
(
null
,
null
,
null
,
null
);
c2
.
getMetaData
().
getTables
(
null
,
null
,
null
,
null
);
stat
.
execute
(
"drop table test"
+
x
+
"_"
+
i
);
stat
.
execute
(
"drop table test"
+
x
+
"_"
+
i
);
}
}
}
finally
{
c2
.
close
();
}
}
}
}
};
};
...
@@ -116,17 +113,14 @@ public class TestMultiThread extends TestBase implements Runnable {
...
@@ -116,17 +113,14 @@ public class TestMultiThread extends TestBase implements Runnable {
Task
t
=
new
Task
()
{
Task
t
=
new
Task
()
{
@Override
@Override
public
void
call
()
throws
Exception
{
public
void
call
()
throws
Exception
{
Connection
c2
=
getConnection
(
url
);
try
(
Connection
c2
=
getConnection
(
url
))
{
PreparedStatement
p2
=
c2
PreparedStatement
p2
=
c2
.
prepareStatement
(
"insert into test(data) values(?)"
);
.
prepareStatement
(
"insert into test(data) values(?)"
);
try
{
while
(!
stop
)
{
while
(!
stop
)
{
p2
.
setCharacterStream
(
1
,
new
StringReader
(
new
String
(
p2
.
setCharacterStream
(
1
,
new
StringReader
(
new
String
(
new
char
[
10
*
1024
])));
new
char
[
10
*
1024
])));
p2
.
execute
();
p2
.
execute
();
}
}
}
finally
{
c2
.
close
();
}
}
}
}
};
};
...
...
h2/src/test/org/h2/test/db/TestSequence.java
浏览文件 @
0a92f254
...
@@ -13,7 +13,6 @@ import java.sql.Statement;
...
@@ -13,7 +13,6 @@ import java.sql.Statement;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
org.h2.api.Trigger
;
import
org.h2.api.Trigger
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.util.Task
;
import
org.h2.util.Task
;
...
@@ -64,8 +63,7 @@ public class TestSequence extends TestBase {
...
@@ -64,8 +63,7 @@ public class TestSequence extends TestBase {
tasks
[
i
]
=
new
Task
()
{
tasks
[
i
]
=
new
Task
()
{
@Override
@Override
public
void
call
()
throws
Exception
{
public
void
call
()
throws
Exception
{
Connection
conn
=
getConnection
(
url
);
try
(
Connection
conn
=
getConnection
(
url
))
{
try
{
PreparedStatement
prep
=
conn
.
prepareStatement
(
PreparedStatement
prep
=
conn
.
prepareStatement
(
"insert into test(id) values(next value for test_seq)"
);
"insert into test(id) values(next value for test_seq)"
);
PreparedStatement
prep2
=
conn
.
prepareStatement
(
PreparedStatement
prep2
=
conn
.
prepareStatement
(
...
@@ -79,8 +77,6 @@ public class TestSequence extends TestBase {
...
@@ -79,8 +77,6 @@ public class TestSequence extends TestBase {
createDropTrigger
(
conn
);
createDropTrigger
(
conn
);
}
}
}
}
}
finally
{
conn
.
close
();
}
}
}
}
...
...
h2/src/test/org/h2/test/db/TestSpatial.java
浏览文件 @
0a92f254
差异被折叠。
点击展开。
h2/src/test/org/h2/test/jdbc/TestLimitUpdates.java
浏览文件 @
0a92f254
...
@@ -105,17 +105,11 @@ public class TestLimitUpdates extends TestBase {
...
@@ -105,17 +105,11 @@ public class TestLimitUpdates extends TestBase {
private
static
void
updateLimit
(
final
Connection
conn
,
final
int
value
,
private
static
void
updateLimit
(
final
Connection
conn
,
final
int
value
,
final
int
limit
)
throws
SQLException
{
final
int
limit
)
throws
SQLException
{
PreparedStatement
prep
=
null
;
try
(
PreparedStatement
prep
=
conn
.
prepareStatement
(
try
{
"UPDATE TEST SET VALUE_ID = ? LIMIT ?"
))
{
prep
=
conn
.
prepareStatement
(
"UPDATE TEST SET VALUE_ID = ? LIMIT ?"
);
prep
.
setInt
(
1
,
value
);
prep
.
setInt
(
1
,
value
);
prep
.
setInt
(
2
,
limit
);
prep
.
setInt
(
2
,
limit
);
prep
.
execute
();
prep
.
execute
();
}
finally
{
if
(
prep
!=
null
)
{
prep
.
close
();
}
}
}
}
}
}
}
h2/src/test/org/h2/test/poweroff/TestRecover.java
浏览文件 @
0a92f254
...
@@ -12,7 +12,6 @@ import java.io.IOException;
...
@@ -12,7 +12,6 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
import
java.util.Date
;
import
java.security.SecureRandom
;
import
java.security.SecureRandom
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.Driver
;
import
java.sql.Driver
;
...
@@ -23,11 +22,11 @@ import java.sql.SQLException;
...
@@ -23,11 +22,11 @@ import java.sql.SQLException;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Random
;
import
java.util.Random
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipOutputStream
;
import
java.util.zip.ZipOutputStream
;
import
org.h2.util.IOUtils
;
import
org.h2.util.IOUtils
;
import
org.h2.util.New
;
import
org.h2.util.New
;
...
@@ -133,12 +132,9 @@ public class TestRecover {
...
@@ -133,12 +132,9 @@ public class TestRecover {
}
}
ZipEntry
entry
=
new
ZipEntry
(
basePath
+
entryName
);
ZipEntry
entry
=
new
ZipEntry
(
basePath
+
entryName
);
zipOut
.
putNextEntry
(
entry
);
zipOut
.
putNextEntry
(
entry
);
InputStream
in
=
null
;
try
{
try
(
InputStream
in
=
new
FileInputStream
(
fileName
))
{
in
=
new
FileInputStream
(
fileName
);
IOUtils
.
copyAndCloseInput
(
in
,
zipOut
);
IOUtils
.
copyAndCloseInput
(
in
,
zipOut
);
}
finally
{
IOUtils
.
closeSilently
(
in
);
}
}
zipOut
.
closeEntry
();
zipOut
.
closeEntry
();
}
}
...
...
h2/src/test/org/h2/test/synth/TestHalt.java
浏览文件 @
0a92f254
...
@@ -16,13 +16,11 @@ import java.sql.SQLException;
...
@@ -16,13 +16,11 @@ import java.sql.SQLException;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.Random
;
import
java.util.Random
;
import
org.h2.test.TestAll
;
import
org.h2.test.TestAll
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.test.utils.SelfDestructor
;
import
org.h2.test.utils.SelfDestructor
;
import
org.h2.tools.Backup
;
import
org.h2.tools.Backup
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.tools.DeleteDbFiles
;
import
org.h2.util.IOUtils
;
import
org.h2.util.StringUtils
;
import
org.h2.util.StringUtils
;
/**
/**
...
@@ -188,11 +186,9 @@ public abstract class TestHalt extends TestBase {
...
@@ -188,11 +186,9 @@ public abstract class TestHalt extends TestBase {
* @param e the exception or null
* @param e the exception or null
*/
*/
protected
void
traceOperation
(
String
s
,
Exception
e
)
{
protected
void
traceOperation
(
String
s
,
Exception
e
)
{
FileWriter
writer
=
null
;
File
f
=
new
File
(
getBaseDir
()
+
"/"
+
TRACE_FILE_NAME
);
try
{
f
.
getParentFile
().
mkdirs
();
File
f
=
new
File
(
getBaseDir
()
+
"/"
+
TRACE_FILE_NAME
);
try
(
FileWriter
writer
=
new
FileWriter
(
f
,
true
))
{
f
.
getParentFile
().
mkdirs
();
writer
=
new
FileWriter
(
f
,
true
);
PrintWriter
w
=
new
PrintWriter
(
writer
);
PrintWriter
w
=
new
PrintWriter
(
writer
);
s
=
dateFormat
.
format
(
new
Date
())
+
": "
+
s
;
s
=
dateFormat
.
format
(
new
Date
())
+
": "
+
s
;
w
.
println
(
s
);
w
.
println
(
s
);
...
@@ -201,8 +197,6 @@ public abstract class TestHalt extends TestBase {
...
@@ -201,8 +197,6 @@ public abstract class TestHalt extends TestBase {
}
}
}
catch
(
IOException
e2
)
{
}
catch
(
IOException
e2
)
{
e2
.
printStackTrace
();
e2
.
printStackTrace
();
}
finally
{
IOUtils
.
closeSilently
(
writer
);
}
}
}
}
...
...
h2/src/test/org/h2/test/unit/TestBnf.java
浏览文件 @
0a92f254
...
@@ -5,6 +5,10 @@
...
@@ -5,6 +5,10 @@
*/
*/
package
org
.
h2
.
test
.
unit
;
package
org
.
h2
.
test
.
unit
;
import
java.sql.Connection
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Set
;
import
org.h2.bnf.Bnf
;
import
org.h2.bnf.Bnf
;
import
org.h2.bnf.context.DbContents
;
import
org.h2.bnf.context.DbContents
;
import
org.h2.bnf.context.DbContextRule
;
import
org.h2.bnf.context.DbContextRule
;
...
@@ -12,11 +16,6 @@ import org.h2.bnf.context.DbProcedure;
...
@@ -12,11 +16,6 @@ import org.h2.bnf.context.DbProcedure;
import
org.h2.bnf.context.DbSchema
;
import
org.h2.bnf.context.DbSchema
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
java.sql.Connection
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Set
;
/**
/**
* Test Bnf Sql parser
* Test Bnf Sql parser
* @author Nicolas Fortin
* @author Nicolas Fortin
...
@@ -35,18 +34,12 @@ public class TestBnf extends TestBase {
...
@@ -35,18 +34,12 @@ public class TestBnf extends TestBase {
@Override
@Override
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
deleteDb
(
"bnf"
);
deleteDb
(
"bnf"
);
Connection
conn
=
getConnection
(
"bnf"
);
try
(
Connection
conn
=
getConnection
(
"bnf"
))
{
try
{
testModes
(
conn
);
testModes
(
conn
);
testProcedures
(
conn
,
false
);
testProcedures
(
conn
,
false
);
}
finally
{
conn
.
close
();
}
}
conn
=
getConnection
(
"bnf;mode=mysql"
);
try
(
Connection
conn
=
getConnection
(
"bnf;mode=mysql"
))
{
try
{
testProcedures
(
conn
,
true
);
testProcedures
(
conn
,
true
);
}
finally
{
conn
.
close
();
}
}
}
}
...
...
h2/src/test/org/h2/test/unit/TestFileLockSerialized.java
浏览文件 @
0a92f254
...
@@ -13,7 +13,6 @@ import java.sql.SQLException;
...
@@ -13,7 +13,6 @@ import java.sql.SQLException;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.CountDownLatch
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.jdbc.JdbcConnection
;
import
org.h2.jdbc.JdbcConnection
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
...
@@ -237,11 +236,8 @@ public class TestFileLockSerialized extends TestBase {
...
@@ -237,11 +236,8 @@ public class TestFileLockSerialized extends TestBase {
SortedProperties
p
=
SortedProperties
.
loadProperties
(
propFile
);
SortedProperties
p
=
SortedProperties
.
loadProperties
(
propFile
);
p
.
setProperty
(
"changePending"
,
"true"
);
p
.
setProperty
(
"changePending"
,
"true"
);
p
.
setProperty
(
"modificationDataId"
,
"1000"
);
p
.
setProperty
(
"modificationDataId"
,
"1000"
);
OutputStream
out
=
FileUtils
.
newOutputStream
(
propFile
,
false
);
try
(
OutputStream
out
=
FileUtils
.
newOutputStream
(
propFile
,
false
))
{
try
{
p
.
store
(
out
,
"test"
);
p
.
store
(
out
,
"test"
);
}
finally
{
out
.
close
();
}
}
Thread
.
sleep
(
100
);
Thread
.
sleep
(
100
);
stat
.
execute
(
"select * from test"
);
stat
.
execute
(
"select * from test"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论