Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
bbb45884
Unverified
提交
bbb45884
authored
1月 15, 2018
作者:
Prashant Bhat
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make use of try-with-resources statement
上级
969f44a9
显示空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
16 行增加
和
47 行删除
+16
-47
RunScript.java
h2/src/main/org/h2/tools/RunScript.java
+1
-4
ValueLobDb.java
h2/src/main/org/h2/value/ValueLobDb.java
+1
-4
TestMergeUsing.java
h2/src/test/org/h2/test/db/TestMergeUsing.java
+5
-11
TestSpatial.java
h2/src/test/org/h2/test/db/TestSpatial.java
+2
-5
TestBtreeIndex.java
h2/src/test/org/h2/test/synth/TestBtreeIndex.java
+1
-4
TestValue.java
h2/src/test/org/h2/test/unit/TestValue.java
+2
-6
SwitchSource.java
h2/src/tools/org/h2/build/code/SwitchSource.java
+1
-4
PropertiesToUTF8.java
h2/src/tools/org/h2/build/i18n/PropertiesToUTF8.java
+2
-5
ArchiveToolStore.java
h2/src/tools/org/h2/dev/fs/ArchiveToolStore.java
+1
-4
没有找到文件。
h2/src/main/org/h2/tools/RunScript.java
浏览文件 @
bbb45884
...
...
@@ -322,14 +322,11 @@ public class RunScript extends Tool {
boolean
continueOnError
)
throws
SQLException
{
try
{
org
.
h2
.
Driver
.
load
();
Connection
conn
=
DriverManager
.
getConnection
(
url
,
user
,
password
);
if
(
charset
==
null
)
{
charset
=
StandardCharsets
.
UTF_8
;
}
try
{
try
(
Connection
conn
=
DriverManager
.
getConnection
(
url
,
user
,
password
))
{
process
(
conn
,
fileName
,
continueOnError
,
charset
);
}
finally
{
conn
.
close
();
}
}
catch
(
IOException
e
)
{
throw
DbException
.
convertIOException
(
e
,
fileName
);
...
...
h2/src/main/org/h2/value/ValueLobDb.java
浏览文件 @
bbb45884
...
...
@@ -133,10 +133,9 @@ public class ValueLobDb extends Value implements Value.ValueClob,
this
.
fileName
=
createTempLobFileName
(
handler
);
this
.
tempFile
=
this
.
handler
.
openFile
(
fileName
,
"rw"
,
false
);
this
.
tempFile
.
autoDelete
();
FileStoreOutputStream
out
=
new
FileStoreOutputStream
(
tempFile
,
null
,
null
);
long
tmpPrecision
=
0
;
boolean
compress
=
this
.
handler
.
getLobCompressionAlgorithm
(
Value
.
BLOB
)
!=
null
;
try
{
try
(
FileStoreOutputStream
out
=
new
FileStoreOutputStream
(
tempFile
,
null
,
null
))
{
while
(
true
)
{
tmpPrecision
+=
len
;
out
.
write
(
buff
,
0
,
len
);
...
...
@@ -150,8 +149,6 @@ public class ValueLobDb extends Value implements Value.ValueClob,
break
;
}
}
}
finally
{
out
.
close
();
}
this
.
precision
=
tmpPrecision
;
this
.
tableId
=
0
;
...
...
h2/src/test/org/h2/test/db/TestMergeUsing.java
浏览文件 @
bbb45884
...
...
@@ -286,22 +286,17 @@ public class TestMergeUsing extends TestBase implements Trigger {
String
gatherResultsSQL
,
String
expectedResultsSQL
,
int
expectedRowUpdateCount
)
throws
Exception
{
deleteDb
(
"mergeUsingQueries"
);
Connection
conn
=
getConnection
(
"mergeUsingQueries"
);
Statement
stat
;
PreparedStatement
prep
;
ResultSet
rs
;
int
rowCountUpdate
;
try
{
stat
=
conn
.
createStatement
();
try
(
Connection
conn
=
getConnection
(
"mergeUsingQueries"
))
{
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
setupSQL
);
prep
=
conn
.
prepareStatement
(
statementUnderTest
);
rowCountUpdate
=
prep
.
executeUpdate
();
PreparedStatement
prep
=
conn
.
prepareStatement
(
statementUnderTest
);
int
rowCountUpdate
=
prep
.
executeUpdate
();
// compare actual results from SQL result set with expected results
// - by diffing (aka set MINUS operation)
rs
=
stat
.
executeQuery
(
"( "
+
gatherResultsSQL
+
" ) MINUS ( "
ResultSet
rs
=
stat
.
executeQuery
(
"( "
+
gatherResultsSQL
+
" ) MINUS ( "
+
expectedResultsSQL
+
" )"
);
int
rowCount
=
0
;
...
...
@@ -319,7 +314,6 @@ public class TestMergeUsing extends TestBase implements Trigger {
assertEquals
(
"Expected update counts differ"
,
expectedRowUpdateCount
,
rowCountUpdate
);
}
finally
{
conn
.
close
();
deleteDb
(
"mergeUsingQueries"
);
}
}
...
...
h2/src/test/org/h2/test/db/TestSpatial.java
浏览文件 @
bbb45884
...
...
@@ -877,15 +877,12 @@ public class TestSpatial extends TestBase {
"SELECT null, CONCAT('POINT(',A.X,' ',B.X,')')::geometry the_geom "
+
"from system_range(0,120) A,system_range(0,10) B;"
);
stat
.
execute
(
"create spatial index on pt_cloud(the_geom);"
);
ResultSet
rs
=
stat
.
executeQuery
(
try
(
ResultSet
rs
=
stat
.
executeQuery
(
"explain select * from PT_CLOUD "
+
"where the_geom && 'POINT(1 1)'"
);
try
{
"where the_geom && 'POINT(1 1)'"
))
{
assertTrue
(
rs
.
next
());
assertFalse
(
"H2 should use spatial index got this explain:\n"
+
rs
.
getString
(
1
),
rs
.
getString
(
1
).
contains
(
"tableScan"
));
}
finally
{
rs
.
close
();
}
}
deleteDb
(
"spatial"
);
...
...
h2/src/test/org/h2/test/synth/TestBtreeIndex.java
浏览文件 @
bbb45884
...
...
@@ -102,8 +102,7 @@ public class TestBtreeIndex extends TestBase {
}
String
prefix
=
buff
.
toString
().
substring
(
0
,
prefixLength
);
DeleteDbFiles
.
execute
(
getBaseDir
()
+
"/"
+
getTestName
(),
null
,
true
);
Connection
conn
=
getConnection
(
getTestName
());
try
{
try
(
Connection
conn
=
getConnection
(
getTestName
()))
{
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE a(text VARCHAR PRIMARY KEY)"
);
PreparedStatement
prepInsert
=
conn
.
prepareStatement
(
...
...
@@ -189,8 +188,6 @@ public class TestBtreeIndex extends TestBase {
if
(
rs
.
next
())
{
printError
(
seed
,
"testCount:"
+
testCount
+
" "
+
rs
.
getString
(
1
));
}
}
finally
{
conn
.
close
();
}
deleteDb
(
getTestName
());
}
...
...
h2/src/test/org/h2/test/unit/TestValue.java
浏览文件 @
bbb45884
...
...
@@ -121,8 +121,7 @@ public class TestValue extends TestBase {
}
private
void
testBinaryAndUuid
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"binaryAndUuid"
);
try
{
try
(
Connection
conn
=
getConnection
(
"binaryAndUuid"
))
{
UUID
uuid
=
UUID
.
randomUUID
();
PreparedStatement
prep
;
ResultSet
rs
;
...
...
@@ -139,7 +138,6 @@ public class TestValue extends TestBase {
rs
.
next
();
assertEquals
(
uuid
,
rs
.
getObject
(
1
));
}
finally
{
conn
.
close
();
deleteDb
(
"binaryAndUuid"
);
}
}
...
...
@@ -356,13 +354,11 @@ public class TestValue extends TestBase {
}
private
void
testModulusOperator
()
throws
SQLException
{
Connection
conn
=
getConnection
(
"modulus"
);
try
{
try
(
Connection
conn
=
getConnection
(
"modulus"
))
{
ResultSet
rs
=
conn
.
createStatement
().
executeQuery
(
"CALL 12 % 10"
);
rs
.
next
();
assertEquals
(
2
,
rs
.
getInt
(
1
));
}
finally
{
conn
.
close
();
deleteDb
(
"modulus"
);
}
}
...
...
h2/src/tools/org/h2/build/code/SwitchSource.java
浏览文件 @
bbb45884
...
...
@@ -100,17 +100,14 @@ public class SwitchSource {
}
private
void
processFile
(
File
f
)
throws
IOException
{
RandomAccessFile
read
=
new
RandomAccessFile
(
f
,
"r"
);
byte
[]
buffer
;
try
{
try
(
RandomAccessFile
read
=
new
RandomAccessFile
(
f
,
"r"
))
{
long
len
=
read
.
length
();
if
(
len
>=
Integer
.
MAX_VALUE
)
{
throw
new
IOException
(
"Files bigger than Integer.MAX_VALUE are not supported"
);
}
buffer
=
new
byte
[(
int
)
len
];
read
.
readFully
(
buffer
);
}
finally
{
read
.
close
();
}
boolean
found
=
false
;
// check for ## without creating a string
...
...
h2/src/tools/org/h2/build/i18n/PropertiesToUTF8.java
浏览文件 @
bbb45884
...
...
@@ -79,9 +79,8 @@ public class PropertiesToUTF8 {
if
(!
new
File
(
source
).
exists
())
{
return
;
}
LineNumberReader
reader
=
new
LineNumberReader
(
new
InputStreamReader
(
new
FileInputStream
(
source
),
StandardCharsets
.
UTF_8
));
try
{
try
(
LineNumberReader
reader
=
new
LineNumberReader
(
new
InputStreamReader
(
new
FileInputStream
(
source
),
StandardCharsets
.
UTF_8
)))
{
SortedProperties
prop
=
new
SortedProperties
();
StringBuilder
buff
=
new
StringBuilder
();
String
key
=
null
;
...
...
@@ -113,8 +112,6 @@ public class PropertiesToUTF8 {
prop
.
setProperty
(
key
,
buff
.
toString
());
}
prop
.
store
(
target
);
}
finally
{
reader
.
close
();
}
}
...
...
h2/src/tools/org/h2/dev/fs/ArchiveToolStore.java
浏览文件 @
bbb45884
...
...
@@ -101,8 +101,7 @@ public class ArchiveToolStore {
buff
.
clear
();
buff
.
flip
();
ArrayList
<
Integer
>
posList
=
new
ArrayList
<>();
FileChannel
fc
=
FileUtils
.
open
(
s
,
"r"
);
try
{
try
(
FileChannel
fc
=
FileUtils
.
open
(
s
,
"r"
))
{
boolean
eof
=
false
;
while
(
true
)
{
while
(!
eof
&&
buff
.
remaining
()
<
512
*
1024
)
{
...
...
@@ -153,8 +152,6 @@ public class ArchiveToolStore {
}
printProgress
(
0
,
50
,
currentSize
,
totalSize
);
}
}
finally
{
fc
.
close
();
}
int
[]
posArray
=
new
int
[
posList
.
size
()];
for
(
int
i
=
0
;
i
<
posList
.
size
();
i
++)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论