Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
83d0a51a
Unverified
提交
83d0a51a
authored
5月 21, 2018
作者:
Noel Grandin
提交者:
GitHub
5月 21, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1152 from grandinj/dbexception_getsqlexception
skip intermediate DbException object when creating SQLException
上级
fb08a1fa
a69cbea6
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
42 行增加
和
28 行删除
+42
-28
DbException.java
h2/src/main/org/h2/message/DbException.java
+24
-2
FileLister.java
h2/src/main/org/h2/store/FileLister.java
+4
-5
LobStorageBackend.java
h2/src/main/org/h2/store/LobStorageBackend.java
+6
-8
Csv.java
h2/src/main/org/h2/tools/Csv.java
+1
-2
SimpleResultSet.java
h2/src/main/org/h2/tools/SimpleResultSet.java
+5
-8
Tool.java
h2/src/main/org/h2/util/Tool.java
+2
-3
没有找到文件。
h2/src/main/org/h2/message/DbException.java
浏览文件 @
83d0a51a
...
@@ -16,7 +16,6 @@ import java.text.MessageFormat;
...
@@ -16,7 +16,6 @@ import java.text.MessageFormat;
import
java.util.Locale
;
import
java.util.Locale
;
import
java.util.Map.Entry
;
import
java.util.Map.Entry
;
import
java.util.Properties
;
import
java.util.Properties
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.jdbc.JdbcSQLException
;
import
org.h2.jdbc.JdbcSQLException
;
import
org.h2.util.SortedProperties
;
import
org.h2.util.SortedProperties
;
...
@@ -342,6 +341,29 @@ public class DbException extends RuntimeException {
...
@@ -342,6 +341,29 @@ public class DbException extends RuntimeException {
return
get
(
ErrorCode
.
IO_EXCEPTION_2
,
e
,
e
.
toString
(),
message
);
return
get
(
ErrorCode
.
IO_EXCEPTION_2
,
e
,
e
.
toString
(),
message
);
}
}
/**
* Gets the SQL exception object for a specific error code.
*
* @param errorCode the error code
* @return the SQLException object
*/
public
static
SQLException
getJdbcSQLException
(
int
errorCode
)
{
return
getJdbcSQLException
(
errorCode
,
(
Throwable
)
null
);
}
/**
* Gets the SQL exception object for a specific error code.
*
* @param errorCode the error code
* @param p1 the first parameter of the message
* @return the SQLException object
*/
public
static
SQLException
getJdbcSQLException
(
int
errorCode
,
String
p1
)
{
return
getJdbcSQLException
(
errorCode
,
null
,
p1
);
}
/**
/**
* Gets the SQL exception object for a specific error code.
* Gets the SQL exception object for a specific error code.
*
*
...
@@ -350,7 +372,7 @@ public class DbException extends RuntimeException {
...
@@ -350,7 +372,7 @@ public class DbException extends RuntimeException {
* @param params the list of parameters of the message
* @param params the list of parameters of the message
* @return the SQLException object
* @return the SQLException object
*/
*/
p
rivate
static
JdbcSQLException
getJdbcSQLException
(
int
errorCode
,
p
ublic
static
JdbcSQLException
getJdbcSQLException
(
int
errorCode
,
Throwable
cause
,
String
...
params
)
{
Throwable
cause
,
String
...
params
)
{
String
sqlstate
=
ErrorCode
.
getState
(
errorCode
);
String
sqlstate
=
ErrorCode
.
getState
(
errorCode
);
String
message
=
translate
(
sqlstate
,
params
);
String
message
=
translate
(
sqlstate
,
params
);
...
...
h2/src/main/org/h2/store/FileLister.java
浏览文件 @
83d0a51a
...
@@ -9,7 +9,6 @@ import java.nio.channels.FileChannel;
...
@@ -9,7 +9,6 @@ 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
;
...
@@ -44,18 +43,18 @@ public class FileLister {
...
@@ -44,18 +43,18 @@ public class FileLister {
lock
.
lock
(
FileLockMethod
.
FILE
);
lock
.
lock
(
FileLockMethod
.
FILE
);
lock
.
unlock
();
lock
.
unlock
();
}
catch
(
DbException
e
)
{
}
catch
(
DbException
e
)
{
throw
DbException
.
get
(
throw
DbException
.
get
JdbcSQLException
(
ErrorCode
.
CANNOT_CHANGE_SETTING_WHEN_OPEN_1
,
ErrorCode
.
CANNOT_CHANGE_SETTING_WHEN_OPEN_1
,
message
)
.
getSQLException
()
;
message
);
}
}
}
else
if
(
fileName
.
endsWith
(
Constants
.
SUFFIX_MV_FILE
))
{
}
else
if
(
fileName
.
endsWith
(
Constants
.
SUFFIX_MV_FILE
))
{
try
(
FileChannel
f
=
FilePath
.
get
(
fileName
).
open
(
"r"
))
{
try
(
FileChannel
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
JdbcSQLException
(
ErrorCode
.
CANNOT_CHANGE_SETTING_WHEN_OPEN_1
,
e
,
ErrorCode
.
CANNOT_CHANGE_SETTING_WHEN_OPEN_1
,
e
,
message
)
.
getSQLException
()
;
message
);
}
}
}
}
}
}
...
...
h2/src/main/org/h2/store/LobStorageBackend.java
浏览文件 @
83d0a51a
...
@@ -15,7 +15,6 @@ import java.sql.Statement;
...
@@ -15,7 +15,6 @@ import java.sql.Statement;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.engine.Database
;
import
org.h2.engine.Database
;
import
org.h2.engine.SysProperties
;
import
org.h2.engine.SysProperties
;
...
@@ -227,9 +226,8 @@ public class LobStorageBackend implements LobStorageInterface {
...
@@ -227,9 +226,8 @@ public class LobStorageBackend implements LobStorageInterface {
prep
.
setLong
(
1
,
block
);
prep
.
setLong
(
1
,
block
);
ResultSet
rs
=
prep
.
executeQuery
();
ResultSet
rs
=
prep
.
executeQuery
();
if
(!
rs
.
next
())
{
if
(!
rs
.
next
())
{
throw
DbException
.
get
(
ErrorCode
.
IO_EXCEPTION_1
,
throw
DbException
.
getJdbcSQLException
(
ErrorCode
.
IO_EXCEPTION_1
,
"Missing lob entry, block: "
+
block
)
"Missing lob entry, block: "
+
block
);
.
getSQLException
();
}
}
int
compressed
=
rs
.
getInt
(
1
);
int
compressed
=
rs
.
getInt
(
1
);
byte
[]
buffer
=
rs
.
getBytes
(
2
);
byte
[]
buffer
=
rs
.
getBytes
(
2
);
...
@@ -646,8 +644,8 @@ public class LobStorageBackend implements LobStorageInterface {
...
@@ -646,8 +644,8 @@ public class LobStorageBackend implements LobStorageInterface {
prep
.
setLong
(
1
,
lobId
);
prep
.
setLong
(
1
,
lobId
);
ResultSet
rs
=
prep
.
executeQuery
();
ResultSet
rs
=
prep
.
executeQuery
();
if
(!
rs
.
next
())
{
if
(!
rs
.
next
())
{
throw
DbException
.
get
(
ErrorCode
.
IO_EXCEPTION_1
,
throw
DbException
.
get
JdbcSQLException
(
ErrorCode
.
IO_EXCEPTION_1
,
"Missing lob entry: "
+
lobId
)
.
getSQLException
()
;
"Missing lob entry: "
+
lobId
);
}
}
byteCount
=
rs
.
getLong
(
1
);
byteCount
=
rs
.
getLong
(
1
);
reuse
(
sql
,
prep
);
reuse
(
sql
,
prep
);
...
@@ -661,8 +659,8 @@ public class LobStorageBackend implements LobStorageInterface {
...
@@ -661,8 +659,8 @@ public class LobStorageBackend implements LobStorageInterface {
rs
.
next
();
rs
.
next
();
int
lobMapCount
=
rs
.
getInt
(
1
);
int
lobMapCount
=
rs
.
getInt
(
1
);
if
(
lobMapCount
==
0
)
{
if
(
lobMapCount
==
0
)
{
throw
DbException
.
get
(
ErrorCode
.
IO_EXCEPTION_1
,
throw
DbException
.
get
JdbcSQLException
(
ErrorCode
.
IO_EXCEPTION_1
,
"Missing lob entry: "
+
lobId
)
.
getSQLException
()
;
"Missing lob entry: "
+
lobId
);
}
}
reuse
(
sql
,
prep
);
reuse
(
sql
,
prep
);
...
...
h2/src/main/org/h2/tools/Csv.java
浏览文件 @
83d0a51a
...
@@ -23,7 +23,6 @@ import java.sql.SQLException;
...
@@ -23,7 +23,6 @@ import java.sql.SQLException;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
java.sql.Types
;
import
java.sql.Types
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.engine.SysProperties
;
import
org.h2.engine.SysProperties
;
...
@@ -587,7 +586,7 @@ public class Csv implements SimpleRowSource {
...
@@ -587,7 +586,7 @@ public class Csv implements SimpleRowSource {
}
}
private
static
SQLException
convertException
(
String
message
,
Exception
e
)
{
private
static
SQLException
convertException
(
String
message
,
Exception
e
)
{
return
DbException
.
get
(
ErrorCode
.
IO_EXCEPTION_1
,
e
,
message
).
getSQLException
(
);
return
DbException
.
get
JdbcSQLException
(
ErrorCode
.
IO_EXCEPTION_1
,
e
,
message
);
}
}
/**
/**
...
...
h2/src/main/org/h2/tools/SimpleResultSet.java
浏览文件 @
83d0a51a
...
@@ -242,7 +242,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData,
...
@@ -242,7 +242,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData,
@Override
@Override
public
void
beforeFirst
()
throws
SQLException
{
public
void
beforeFirst
()
throws
SQLException
{
if
(
autoClose
)
{
if
(
autoClose
)
{
throw
DbException
.
get
(
ErrorCode
.
RESULT_SET_NOT_SCROLLABLE
).
getSQLException
(
);
throw
DbException
.
get
JdbcSQLException
(
ErrorCode
.
RESULT_SET_NOT_SCROLLABLE
);
}
}
rowId
=
-
1
;
rowId
=
-
1
;
if
(
source
!=
null
)
{
if
(
source
!=
null
)
{
...
@@ -278,8 +278,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData,
...
@@ -278,8 +278,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData,
}
}
}
}
}
}
throw
DbException
.
get
(
ErrorCode
.
COLUMN_NOT_FOUND_1
,
columnLabel
)
throw
DbException
.
getJdbcSQLException
(
ErrorCode
.
COLUMN_NOT_FOUND_1
,
columnLabel
);
.
getSQLException
();
}
}
/**
/**
...
@@ -2264,13 +2263,12 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData,
...
@@ -2264,13 +2263,12 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData,
* INTERNAL
* INTERNAL
*/
*/
static
SQLException
getUnsupportedException
()
{
static
SQLException
getUnsupportedException
()
{
return
DbException
.
get
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
).
return
DbException
.
getJdbcSQLException
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
);
getSQLException
();
}
}
private
void
checkClosed
()
throws
SQLException
{
private
void
checkClosed
()
throws
SQLException
{
if
(
columns
==
null
)
{
if
(
columns
==
null
)
{
throw
DbException
.
get
(
ErrorCode
.
OBJECT_CLOSED
).
getSQLException
(
);
throw
DbException
.
get
JdbcSQLException
(
ErrorCode
.
OBJECT_CLOSED
);
}
}
}
}
...
@@ -2283,8 +2281,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData,
...
@@ -2283,8 +2281,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData,
private
Object
get
(
int
columnIndex
)
throws
SQLException
{
private
Object
get
(
int
columnIndex
)
throws
SQLException
{
if
(
currentRow
==
null
)
{
if
(
currentRow
==
null
)
{
throw
DbException
.
get
(
ErrorCode
.
NO_DATA_AVAILABLE
).
throw
DbException
.
getJdbcSQLException
(
ErrorCode
.
NO_DATA_AVAILABLE
);
getSQLException
();
}
}
checkColumnIndex
(
columnIndex
);
checkColumnIndex
(
columnIndex
);
columnIndex
--;
columnIndex
--;
...
...
h2/src/main/org/h2/util/Tool.java
浏览文件 @
83d0a51a
...
@@ -10,7 +10,6 @@ import java.io.IOException;
...
@@ -10,7 +10,6 @@ import java.io.IOException;
import
java.io.PrintStream
;
import
java.io.PrintStream
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.Properties
;
import
java.util.Properties
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.store.FileLister
;
import
org.h2.store.FileLister
;
...
@@ -65,8 +64,8 @@ public abstract class Tool {
...
@@ -65,8 +64,8 @@ public abstract class Tool {
*/
*/
protected
SQLException
throwUnsupportedOption
(
String
option
)
protected
SQLException
throwUnsupportedOption
(
String
option
)
throws
SQLException
{
throws
SQLException
{
throw
DbException
.
get
(
throw
DbException
.
get
JdbcSQLException
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
option
)
.
getSQLException
()
;
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
option
);
}
}
/**
/**
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论